diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts
index 148e659365..e5467d1f45 100644
--- a/src/generators/Generator.ts
+++ b/src/generators/Generator.ts
@@ -725,6 +725,10 @@ export default class Generator {
node.__proto__ = nodes[node.type].prototype;
}
+ if (node.type === 'Element') {
+ generator.stylesheet.apply(node);
+ }
+
if (node.type === 'EachBlock') {
node.metadata = contextualise(node.expression, contextDependencies, indexes);
@@ -800,6 +804,22 @@ export default class Generator {
indexes = indexesStack[indexesStack.length - 1];
}
}
+
+ if (node.type === 'Element' && node.name === 'option') {
+ // Special case — treat these the same way:
+ //
+ //
+ const valueAttribute = node.attributes.find((attribute: Node) => attribute.name === 'value');
+
+ if (!valueAttribute) {
+ node.attributes.push(new nodes.Attribute({
+ generator,
+ name: 'value',
+ value: node.children,
+ parent: node
+ }));
+ }
+ }
}
});
}
diff --git a/src/generators/nodes/Attribute.ts b/src/generators/nodes/Attribute.ts
index f83140dadf..44f24712fc 100644
--- a/src/generators/nodes/Attribute.ts
+++ b/src/generators/nodes/Attribute.ts
@@ -162,11 +162,7 @@ export default class Attribute {
updater = `@setInputType(${node.var}, ${shouldCache ? last : value});`;
} else if (isSelectValueAttribute) {
// annoying special case
- const isMultipleSelect =
- node.name === 'select' &&
- node.attributes.find(
- (attr: Attribute) => attr.name.toLowerCase() === 'multiple'
- ); // TODO use getStaticAttributeValue
+ const isMultipleSelect = node.getStaticAttributeValue('multiple');
const i = block.getUniqueName('i');
const option = block.getUniqueName('option');
diff --git a/src/generators/nodes/Element.ts b/src/generators/nodes/Element.ts
index 94809e85cb..2298ff8466 100644
--- a/src/generators/nodes/Element.ts
+++ b/src/generators/nodes/Element.ts
@@ -89,18 +89,6 @@ export default class Element extends Node {
const valueAttribute = this.attributes.find((attribute: Attribute) => attribute.name === 'value');
- // Treat these the same way:
- //
- //
- if (this.name === 'option' && !valueAttribute) {
- this.attributes.push(new Attribute({
- generator: this.generator,
- name: 'value',
- value: this.children,
- parent: this
- }));
- }
-
if (this.name === 'textarea') {
// this is an egregious hack, but it's the easiest way to get