I was looking to make a genuine polyfill for <dialog> (not just a shim), and I found Polymer's CustomElements helpful, but realized too late that the spec required "x-" prefixes.

I still feel like it would be useful to have a means for polyfills to be built according to well-recognized semantics via a standard extension mechanism.

How about something like `document.registerPolyfillElement`?

As I envision it, it would, besides also allowing for elements without hyphens, behave in the same way as `document.registerElement` (I understand this will be replacing `document.register`), but if `document.createElement` would return anything besides `HTMLUnknownElement` for the supplied element name, it would immediately return that element's own constructor (or perhaps throw an exception if no constructor were allowed for that element). This would provide the added convenience of not having to feature detect existing support. Or perhaps `document.registerElement` could be supplied a flag to indicate a polyfill was intended.

(Maybe the mechanism could even allow one to polyfill specific methods of existing elements, taking advantage of `attributeChanged`, for example.)

Thanks,
Brett

Reply via email to