diff --git a/src/compile/nodes/Attribute.ts b/src/compile/nodes/Attribute.ts
index 53996469e910..0165dc98fb81 100644
--- a/src/compile/nodes/Attribute.ts
+++ b/src/compile/nodes/Attribute.ts
@@ -130,9 +130,11 @@ export default class Attribute extends Node {
// xlink is a special case... we could maybe extend this to generic
// namespaced attributes but I'm not sure that's applicable in
// HTML5?
- const method = name.slice(0, 6) === 'xlink:'
- ? '@setXlinkAttribute'
- : '@setAttribute';
+ const method = /-/.test(node.name)
+ ? '@setCustomElementData'
+ : name.slice(0, 6) === 'xlink:'
+ ? '@setXlinkAttribute'
+ : '@setAttribute';
const isLegacyInputType = this.compiler.options.legacy && name === 'type' && this.parent.name === 'input';
diff --git a/src/shared/dom.js b/src/shared/dom.js
index 03aaf8aaeb39..3b823cfaae93 100644
--- a/src/shared/dom.js
+++ b/src/shared/dom.js
@@ -96,6 +96,16 @@ export function setAttributes(node, attributes) {
}
}
+export function setCustomElementData(node, prop, value) {
+ if (prop in node) {
+ node[prop] = value;
+ } else if (value) {
+ setAttribute(node, prop, value);
+ } else {
+ removeAttribute(node, prop);
+ }
+}
+
export function removeAttribute(node, attribute) {
node.removeAttribute(attribute);
}
diff --git a/test/custom-elements/samples/props/main.html b/test/custom-elements/samples/props/main.html
new file mode 100644
index 000000000000..db8465591e1c
--- /dev/null
+++ b/test/custom-elements/samples/props/main.html
@@ -0,0 +1,15 @@
+
{items.length} items
+{items.join(', ')}
+ + \ No newline at end of file diff --git a/test/custom-elements/samples/props/test.js b/test/custom-elements/samples/props/test.js new file mode 100644 index 000000000000..1e95fe3ad281 --- /dev/null +++ b/test/custom-elements/samples/props/test.js @@ -0,0 +1,23 @@ +import * as assert from 'assert'; +import CustomElement from './main.html'; + +export default function (target) { + new CustomElement({ + target + }); + + assert.equal(target.innerHTML, '