-
-
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.
Browse files
Browse the repository at this point in the history
Deconflict variable names
- Loading branch information
Showing
22 changed files
with
152 additions
and
67 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
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 function validateHtml ( validator, html ) { | ||
function visit ( node ) { | ||
if ( node.type === 'EachBlock' ) { | ||
if ( !~validator.names.indexOf( node.context ) ) validator.names.push( node.context ); | ||
if ( node.index && !~validator.names.indexOf( node.index ) ) validator.names.push( node.index ); | ||
} | ||
|
||
if ( node.children ) { | ||
node.children.forEach( visit ); | ||
} | ||
} | ||
|
||
html.children.forEach( visit ); | ||
} |
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,15 @@ | ||
export default { | ||
data: { | ||
array: [ [0,0,0], [0,0,0], [0,0,0] ] | ||
}, | ||
|
||
html: ` | ||
<div> | ||
<span>[ 0, 0 ]</span><span>[ 0, 1 ]</span><span>[ 0, 2 ]</span> | ||
</div><div> | ||
<span>[ 1, 0 ]</span><span>[ 1, 1 ]</span><span>[ 1, 2 ]</span> | ||
</div><div> | ||
<span>[ 2, 0 ]</span><span>[ 2, 1 ]</span><span>[ 2, 2 ]</span> | ||
</div> | ||
` | ||
}; |
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,7 @@ | ||
{{#each array as row, i}} | ||
<div> | ||
{{#each row as cell, j}} | ||
<span>[ {{i}}, {{j}} ]</span> | ||
{{/each}} | ||
</div> | ||
{{/each}} |
Oops, something went wrong.