-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e64f26
commit 659eb32
Showing
14 changed files
with
88 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
export default function counter () { | ||
export default function counter ( used ) { | ||
const counts = {}; | ||
|
||
return function ( label ) { | ||
if ( label in counts ) { | ||
return `${label}${counts[ label ]++}`; | ||
used.forEach( name => counts[ name ] = 1 ); | ||
|
||
return function ( name ) { | ||
if ( name in counts ) { | ||
return `${name}${counts[ name ]++}`; | ||
} | ||
|
||
counts[ label ] = 1; | ||
return label; | ||
counts[ name ] = 1; | ||
return name; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export default { | ||
enter ( generator, node ) { | ||
const name = generator.current.counter( `text` ); | ||
const name = generator.current.getUniqueName( `text` ); | ||
generator.addElement( name, `document.createTextNode( ${JSON.stringify( node.data )} )` ); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>{{index + 1}}: {{widget.name}}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default { | ||
html: `<p>1: foo</p><p>2: bar</p><p>3: baz</p>`, | ||
|
||
test ( assert, component, target ) { | ||
component.set({ | ||
widgets: [ | ||
{ name: 'bish' }, | ||
{ name: 'bosh' } | ||
] | ||
}); | ||
|
||
assert.htmlEqual( target.innerHTML, `<p>1: bish</p><p>2: bosh</p>` ); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{#each widgets as widget, i}} | ||
<Widget widget='{{widget}}' index='{{i}}'/> | ||
{{/each}} | ||
|
||
<script> | ||
import Widget from './Widget.html'; | ||
|
||
export default { | ||
data () { | ||
return { | ||
widgets: [ | ||
{ name: 'foo' }, | ||
{ name: 'bar' }, | ||
{ name: 'baz' } | ||
] | ||
}; | ||
}, | ||
|
||
components: { Widget } | ||
}; | ||
</script> |