Skip to content

Commit 32176c4

Browse files
updated: make sure the slot name attribute will be not passed as slot attribute
1 parent 754a2f3 commit 32176c4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/generators/template/bindings/slot.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {
77
NAME_ATTRIBUTE,
88
SLOT_BINDING_TYPE
99
} from '../constants'
10-
import {createBindingAttributes, createSelectorProperties} from '../utils'
10+
import {
11+
createBindingAttributes,
12+
createSelectorProperties,
13+
getName,
14+
getNodeAttributes
15+
} from '../utils'
1116
import {builders} from '../../../utils/build-types'
1217
import {findAttribute} from '../find'
1318
import {simplePropertyNode} from '../../../utils/custom-ast-nodes'
@@ -34,7 +39,15 @@ export default function createSlotBinding(sourceNode, selectorAttribute, sourceF
3439
),
3540
simplePropertyNode(
3641
BINDING_ATTRIBUTES_KEY,
37-
createBindingAttributes(sourceNode, selectorAttribute, sourceFile, sourceCode)
42+
createBindingAttributes({
43+
...sourceNode,
44+
// filter the name attribute
45+
attributes: getNodeAttributes(sourceNode)
46+
.filter(attribute => getName(attribute) !== NAME_ATTRIBUTE)
47+
},
48+
selectorAttribute,
49+
sourceFile,
50+
sourceCode)
3851
),
3952
simplePropertyNode(
4053
BINDING_NAME_KEY,

test/generators/template.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ describe('Generators - Template', () => {
843843
const output = evaluateOutput(input)
844844

845845
expect(output[BINDING_SELECTOR_KEY]).to.be.equal('[expr0]')
846+
expect(output[BINDING_ATTRIBUTES_KEY]).to.have.length(0)
846847
expect(output[BINDING_TYPE_KEY]).to.be.equal(bindingTypes.SLOT)
847848
expect(output[NAME_ATTRIBUTE]).to.be.equal('foo')
848849
})

0 commit comments

Comments
 (0)