Skip to content

Commit 8d6d010

Browse files
committed
do not remove slot attribute (close #1281)
1 parent accaa14 commit 8d6d010

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/directives/element/slot.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ function extractFragment (nodes, parent, main) {
115115
node = templateParser.parse(node)
116116
}
117117
node = templateParser.clone(node)
118-
if (node.attributes) {
119-
node.removeAttribute('slot')
120-
}
121118
frag.appendChild(node)
122119
}
123120
}

test/unit/specs/directives/element/slot_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('Slot Distribution', function () {
6060
el.innerHTML = '<p slot="t">1</p><div></div><p slot="t">2</p>'
6161
options.template = '<slot name="t"></slot>'
6262
mount()
63-
expect(el.innerHTML).toBe('<p>1</p><p>2</p>')
63+
expect(el.innerHTML).toBe('<p slot="t">1</p><p slot="t">2</p>')
6464
})
6565

6666
it('default content should only render parts not selected', function () {
@@ -70,7 +70,7 @@ describe('Slot Distribution', function () {
7070
'<slot></slot>' +
7171
'<slot name="b"></slot>'
7272
mount()
73-
expect(el.innerHTML).toBe('<p>1</p><div>hi</div><p>2</p>')
73+
expect(el.innerHTML).toBe('<p slot="a">1</p><div>hi</div><p slot="b">2</p>')
7474
})
7575

7676
it('content transclusion with replace', function () {
@@ -126,7 +126,7 @@ describe('Slot Distribution', function () {
126126
theName: 'two'
127127
}
128128
mount()
129-
expect(el.innerHTML).toBe('<p>two</p>')
129+
expect(el.innerHTML).toBe('<p slot="two">two</p>')
130130
})
131131

132132
it('content should be dynamic and compiled in parent scope', function (done) {
@@ -194,7 +194,7 @@ describe('Slot Distribution', function () {
194194
this.list = this.$options._content.querySelectorAll('p').length
195195
}
196196
})
197-
expect(el.innerHTML).toBe('<div><p>1</p></div><div><p>2</p></div><div><p>3</p></div>')
197+
expect(el.innerHTML).toBe('<div><p slot="1">1</p></div><div><p slot="2">2</p></div><div><p slot="3">3</p></div>')
198198
})
199199

200200
it('v-for + component + parent directive + transclusion', function (done) {

0 commit comments

Comments
 (0)