1+ "use strict" ;
12var domino = require ( "domino" ) ;
23var Document = require ( 'domino/lib/Document' ) ;
34var Element = require ( 'domino/lib/Element' ) ;
@@ -210,9 +211,11 @@ exports = module.exports = CustomElementRegistry;
210211
211212
212213//
213- // Overwrite domino's new element constructor
214+ // - Overwrite domino's new element constructor
215+ // - Patch domino's document.createElement
214216//
215217const origHTMLElement = domino . impl . HTMLElement ;
218+ const _origCreateElement = Document . prototype . createElement ;
216219
217220const newHTMLElement = function HTMLElement ( ) {
218221 const customElements = _customElements ( ) ;
@@ -231,16 +234,6 @@ const newHTMLElement = function HTMLElement() {
231234 }
232235 throw new Error ( 'Unknown constructor. Did you call customElements.define()?' ) ;
233236} ;
234- exports . HTMLElement = newHTMLElement ;
235- exports . HTMLElement . prototype = Object . create ( domino . impl . HTMLElement . prototype , {
236- constructor : { value : exports . HTMLElement , configurable : true , writable : true } ,
237- } ) ;
238-
239-
240- //
241- // Patch document.createElement
242- //
243- const _origCreateElement = Document . prototype . createElement ;
244237
245238/**
246239 * Creates a new element and upgrades it if it's a custom element.
@@ -262,23 +255,10 @@ function _createElement(doc, tagName, options, callConstructor) {
262255 }
263256 return element ;
264257}
265- Document . prototype . createElement = function ( tagName , options ) {
266- return _createElement ( this , tagName , options , true ) ;
267- } ;
268258
269- //
270- // Patch doc.createElementNS
271- //
272- const HTMLNS = 'http://www.w3.org/1999/xhtml' ;
273- const _origCreateElementNS = Document . prototype . createElementNS ;
274-
275- Document . prototype . createElementNS = function ( namespaceURI , qualifiedName ) {
276- if ( namespaceURI === 'http://www.w3.org/1999/xhtml' ) {
277- return this . createElement ( qualifiedName ) ;
278- } else {
279- return _origCreateElementNS . call ( this , namespaceURI , qualifiedName ) ;
280- }
281- } ;
259+
260+ var patched = require ( './extend-domino' ) ( newHTMLElement , _createElement ) ;
261+ exports . HTMLElement = patched . HTMLElement ;
282262
283263
284264/**
0 commit comments