diff --git a/src/generators/dom/Block.ts b/src/generators/dom/Block.ts index e7770bccfe..eb803fdba0 100644 --- a/src/generators/dom/Block.ts +++ b/src/generators/dom/Block.ts @@ -14,7 +14,6 @@ export interface BlockOptions { comment?: string; key?: string; contexts?: Map; - contextTypes?: Map; indexes?: Map; changeableIndexes?: Map; indexNames?: Map; @@ -34,7 +33,6 @@ export default class Block { first: string; contexts: Map; - contextTypes: Map; indexes: Map; changeableIndexes: Map; dependencies: Set; @@ -79,7 +77,6 @@ export default class Block { this.first = null; this.contexts = options.contexts; - this.contextTypes = options.contextTypes; this.indexes = options.indexes; this.changeableIndexes = options.changeableIndexes; this.dependencies = new Set(); diff --git a/src/generators/nodes/Attribute.ts b/src/generators/nodes/Attribute.ts index a049d0cbe2..acae032129 100644 --- a/src/generators/nodes/Attribute.ts +++ b/src/generators/nodes/Attribute.ts @@ -112,9 +112,9 @@ export default class Attribute extends Node { name === 'value' && (node.name === 'option' || // TODO check it's actually bound (node.name === 'input' && - node.attributes.find( - (attribute: Attribute) => - attribute.type === 'Binding' && /checked|group/.test(attribute.name) + node.bindings.find( + (binding: Binding) => + /checked|group/.test(binding.name) ))); const propertyName = isIndirectlyBoundValue diff --git a/src/generators/nodes/AwaitBlock.ts b/src/generators/nodes/AwaitBlock.ts index a919f7b1e6..b221fcc5dd 100644 --- a/src/generators/nodes/AwaitBlock.ts +++ b/src/generators/nodes/AwaitBlock.ts @@ -53,14 +53,12 @@ export default class AwaitBlock extends Node { child.block = block.child({ comment: createDebuggingComment(child, this.compiler), name: this.compiler.getUniqueName(`create_${status}_block`), - contexts: new Map(block.contexts), - contextTypes: new Map(block.contextTypes) + contexts: new Map(block.contexts) }); if (arg) { child.block.context = arg; child.block.contexts.set(arg, arg); // TODO should be using getUniqueName - child.block.contextTypes.set(arg, status); } child.initChildren(child.block, stripWhitespace, nextSibling); diff --git a/src/generators/nodes/Binding.ts b/src/generators/nodes/Binding.ts index b377317936..a8a3e821f2 100644 --- a/src/generators/nodes/Binding.ts +++ b/src/generators/nodes/Binding.ts @@ -26,17 +26,10 @@ export default class Binding extends Node { this.name = info.name; this.value = new Expression(compiler, this, scope, info.value); - // const contextual = block.contexts.has(name); - const contextual = false; // TODO - let obj; let prop; - if (contextual) { - // TODO does this need to go later? - obj = `ctx.${block.listNames.get(name)}`; - prop = `${block.indexNames.get(name)}`; - } else if (this.value.node.type === 'MemberExpression') { + if (this.value.node.type === 'MemberExpression') { prop = `[✂${this.value.node.property.start}-${this.value.node.property.end}✂]`; if (!this.value.node.computed) prop = `'${prop}'`; obj = `[✂${this.value.node.object.start}-${this.value.node.object.end}✂]`; diff --git a/src/generators/nodes/EachBlock.ts b/src/generators/nodes/EachBlock.ts index f6b92a8f5b..e8dc64a0b7 100644 --- a/src/generators/nodes/EachBlock.ts +++ b/src/generators/nodes/EachBlock.ts @@ -64,7 +64,6 @@ export default class EachBlock extends Node { key: this.key, contexts: new Map(block.contexts), - contextTypes: new Map(block.contextTypes), indexes: new Map(block.indexes), changeableIndexes: new Map(block.changeableIndexes), @@ -75,7 +74,6 @@ export default class EachBlock extends Node { const listName = this.compiler.getUniqueName('each_value'); const indexName = this.index || this.compiler.getUniqueName(`${this.context}_index`); - this.block.contextTypes.set(this.context, 'each'); this.block.indexNames.set(this.context, indexName); this.block.listNames.set(this.context, listName); diff --git a/src/generators/nodes/Element.ts b/src/generators/nodes/Element.ts index cdcaabb7b1..a9414e9c6d 100644 --- a/src/generators/nodes/Element.ts +++ b/src/generators/nodes/Element.ts @@ -65,6 +65,21 @@ export default class Element extends Node { } } + if (this.name === 'option') { + // Special case — treat these the same way: + // + // + const valueAttribute = info.attributes.find((attribute: Node) => attribute.name === 'value'); + + if (!valueAttribute) { + info.attributes.push({ + type: 'Attribute', + name: 'value', + value: info.children + }); + } + } + info.attributes.forEach(node => { switch (node.type) { case 'Action': @@ -174,8 +189,8 @@ export default class Element extends Node { // special case — in a case like this... // //