Fix typo in generator's contextualise; solves #46

pull/105/head
mrkishi 8 years ago
parent e09a39d34f
commit bf12bb54a7

@ -101,7 +101,7 @@ export default function generate ( parsed, source, options ) {
const context = indexes[ name ]; const context = indexes[ name ];
if ( !~usedContexts.indexOf( context ) ) usedContexts.push( context ); if ( !~usedContexts.indexOf( context ) ) usedContexts.push( context );
} else { } else {
dependencies.push( node.name ); dependencies.push( name );
generator.code.prependRight( node.start, `root.` ); generator.code.prependRight( node.start, `root.` );
if ( !~usedContexts.indexOf( 'root' ) ) usedContexts.push( 'root' ); if ( !~usedContexts.indexOf( 'root' ) ) usedContexts.push( 'root' );
} }

@ -1,3 +1,4 @@
<p>foo: {{foo}}</p> <p>foo: {{foo}}</p>
<p>baz: {{baz}} ({{typeof baz}})</p> <p>baz: {{baz}} ({{typeof baz}})</p>
<p>qux: {{qux}}</p> <p>qux: {{qux}}</p>
<p>quux: {{quux}}</p>

@ -2,16 +2,18 @@ export default {
data: { data: {
bar: 'lol', bar: 'lol',
x: 2, x: 2,
compound: 'piece of' compound: 'piece of',
go: { deeper: 'core' }
}, },
html: `<div><p>foo: lol</p>\n<p>baz: 42 (number)</p>\n<p>qux: this is a piece of string</p></div>`, html: `<div><p>foo: lol</p>\n<p>baz: 42 (number)</p>\n<p>qux: this is a piece of string</p>\n<p>quux: core</p></div>`,
test ( assert, component, target ) { test ( assert, component, target ) {
component.set({ component.set({
bar: 'wut', bar: 'wut',
x: 3, x: 3,
compound: 'rather boring' compound: 'rather boring',
go: { deeper: 'heart' }
}); });
assert.equal( target.innerHTML, `<div><p>foo: wut</p>\n<p>baz: 43 (number)</p>\n<p>qux: this is a rather boring string</p></div>` ); assert.equal( target.innerHTML, `<div><p>foo: wut</p>\n<p>baz: 43 (number)</p>\n<p>qux: this is a rather boring string</p>\n<p>quux: heart</p></div>` );
} }
}; };

@ -1,5 +1,5 @@
<div> <div>
<Widget foo='{{bar}}' baz='{{40 + x}}' qux='this is a {{compound}} string'/> <Widget foo='{{bar}}' baz='{{40 + x}}' qux='this is a {{compound}} string' quux='{{go.deeper}}'/>
</div> </div>
<script> <script>

Loading…
Cancel
Save