diff --git a/src/validate/html/validateElement.ts b/src/validate/html/validateElement.ts index 0d67b8002d..721a91cb6c 100644 --- a/src/validate/html/validateElement.ts +++ b/src/validate/html/validateElement.ts @@ -14,7 +14,7 @@ export default function validateElement( elementStack: Node[] ) { const isComponent = - node.name === ':Self' || validator.components.has(node.name); + node.name === ':Self' || node.name === ':Switch' || validator.components.has(node.name); if (!isComponent && /^[A-Z]/.test(node.name[0])) { // TODO upgrade to validator.error in v2 diff --git a/test/runtime/samples/dynamic-component-bindings/Bar.html b/test/runtime/samples/dynamic-component-bindings/Bar.html new file mode 100644 index 0000000000..f609d76ebe --- /dev/null +++ b/test/runtime/samples/dynamic-component-bindings/Bar.html @@ -0,0 +1,2 @@ +

bar

+ \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings/Foo.html b/test/runtime/samples/dynamic-component-bindings/Foo.html new file mode 100644 index 0000000000..cae76b0573 --- /dev/null +++ b/test/runtime/samples/dynamic-component-bindings/Foo.html @@ -0,0 +1,2 @@ +

foo

+ \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings/_config.js b/test/runtime/samples/dynamic-component-bindings/_config.js new file mode 100644 index 0000000000..b10e1d720b --- /dev/null +++ b/test/runtime/samples/dynamic-component-bindings/_config.js @@ -0,0 +1,33 @@ +export default { + data: { + x: true + }, + + html: ` +

foo

+ + `, + + test(assert, component, target, window) { + let input = target.querySelector('input'); + input.value = 'abc'; + input.dispatchEvent(new window.Event('input')); + + assert.equal(component.get('y'), 'abc'); + + component.set({ + x: false + }); + + assert.htmlEqual(target.innerHTML, ` +

bar

+ + `); + + input = target.querySelector('input'); + input.checked = true; + input.dispatchEvent(new window.Event('change')); + + assert.equal(component.get('z'), true); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings/main.html b/test/runtime/samples/dynamic-component-bindings/main.html new file mode 100644 index 0000000000..179677a19a --- /dev/null +++ b/test/runtime/samples/dynamic-component-bindings/main.html @@ -0,0 +1,12 @@ +<:Switch { x ? Foo : Bar } bind:y bind:z/> + + \ No newline at end of file