Custom Elements polyfill is myopic about SVG
If I write this in Chrome:
<!DOCTYPE html>
<svg>
<circle is="foo-bar" cx="50" cy="50" r="50" fill="red"></circle>
</svg>
and inspect the red circle, its prototype is SVGCircleElement.prototype. Likewise if I follow through with registering a definition, it stays "instanceof SVGCircleElement".
However if I write this:
<!DOCTYPE html>
<script src="polymer/polymer.js"></script>
<element name="foo-bar" extends="circle">
<script>
if (this !== window) {
this.register({prototype: Object.create(SVGCircleElement.prototype, {})});
}
</script>
</element>
<svg>
<circle is="foo-bar" cx="50" cy="50" r="50" fill="red"></circle>
</svg>
then the circle becomes a HTMLUnknownElement.
In general it seems the polyfill assumes "extends" refers to HTML elements, and it also doesn't match up tag names of custom elements with what is on the prototype chain (for example if I make that extends="button", then my circle ends up with a prototype chain that leads to HTMLButtonElement.
Absolutely agree about the issue subject, we semi-consciously avoided thinking about SVG elements. Thanks for bringing it up.
this.register({prototype: Object.create(SVGCircleElement.prototype, {})});
Fwiw, HTMLElementElement.register doesn't take a fully qualified prototype (in the polyfill), it only takes the custom prototype. The suffix prototype chain is established by the system based on the extends attribute.
This is almost the only thing that HTMLElementElement does. This is a general topic we need to discuss more fully I think (apart from the SVG support which would be good too).
+1. It would be wonderful to be able to write higher-level svg-based charting libraries with custom elements.
+1 for SVG support!
+1 for SVG support.
Closing this issue due to age and the release of version 1 release of Polymer - please feel free to re-open if this is incorrect.