diff --git a/src/generators/dom/preprocess.ts b/src/generators/dom/preprocess.ts index a93b2b404807..94b8ea444d76 100644 --- a/src/generators/dom/preprocess.ts +++ b/src/generators/dom/preprocess.ts @@ -309,7 +309,7 @@ const preprocessors = { stripWhitespace: boolean, nextSibling: Node ) => { - if (node.name === 'slot') { + if (node.name === 'slot' || node.name === 'option') { cannotUseInnerHTML(node); } @@ -369,8 +369,6 @@ const preprocessors = { // so that if `foo.qux` changes, we know that we need to // mark `bar` and `baz` as dirty too if (node.name === 'select') { - cannotUseInnerHTML(node); - const value = node.attributes.find( (attribute: Node) => attribute.name === 'value' ); diff --git a/test/runtime/samples/binding-select-optgroup/_config.js b/test/runtime/samples/binding-select-optgroup/_config.js new file mode 100644 index 000000000000..0d651b6654ef --- /dev/null +++ b/test/runtime/samples/binding-select-optgroup/_config.js @@ -0,0 +1,39 @@ +export default { + skip: true, // JSDOM + + html: ` +

Hello Harry!

+ + + `, + + test(assert, component, target, window) { + const select = target.querySelector('select'); + const options = [...target.querySelectorAll('option')]; + + assert.deepEqual(options, select.options); + assert.equal(component.get('name'), 'Harry'); + + const change = new window.Event('change'); + + options[1].selected = true; + select.dispatchEvent(change); + + assert.equal(component.get('name'), 'World'); + assert.htmlEqual(target.innerHTML, ` +

Hello World!

+ + + `); + }, +}; diff --git a/test/runtime/samples/binding-select-optgroup/main.html b/test/runtime/samples/binding-select-optgroup/main.html new file mode 100644 index 000000000000..2160d0e2a8aa --- /dev/null +++ b/test/runtime/samples/binding-select-optgroup/main.html @@ -0,0 +1,8 @@ +

Hello {{name}}!

+ + \ No newline at end of file