W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2014

Custom-elements: document.registerPolyfillElement ?

From: Brett Zamir <brettz9@gmail.com>
Date: Tue, 10 Jun 2014 07:00:03 +0800
Message-ID: <53963C73.5040701@gmail.com>
To: public-webapps@w3.org
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 

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.)

Received on Monday, 9 June 2014 23:00:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:25 UTC