@@ -163,6 +163,51 @@ describe('ShadowRoot', () => {
163
163
} ) ;
164
164
} ) ;
165
165
166
+ describe ( 'createElementNS' , ( ) => {
167
+ it ( 'should create a regular element' , ( ) => {
168
+ const registry = new CustomElementRegistry ( ) ;
169
+ const shadowRoot = getShadowRoot ( registry ) ;
170
+
171
+ const $el = shadowRoot . createElementNS (
172
+ 'http://www.w3.org/1999/xhtml' ,
173
+ 'div'
174
+ ) ;
175
+
176
+ expect ( $el ) . to . not . be . undefined ;
177
+ expect ( $el ) . to . be . instanceof ( HTMLDivElement ) ;
178
+ } ) ;
179
+
180
+ it ( `shouldn't upgrade an element defined in the global registry` , ( ) => {
181
+ const { tagName, CustomElementClass} = getTestElement ( ) ;
182
+ customElements . define ( tagName , CustomElementClass ) ;
183
+ const registry = new CustomElementRegistry ( ) ;
184
+ const shadowRoot = getShadowRoot ( registry ) ;
185
+
186
+ const $el = shadowRoot . createElementNS (
187
+ 'http://www.w3.org/1999/xhtml' ,
188
+ tagName
189
+ ) ;
190
+
191
+ expect ( $el ) . to . not . be . undefined ;
192
+ expect ( $el ) . to . not . be . instanceof ( CustomElementClass ) ;
193
+ } ) ;
194
+
195
+ it ( `should upgrade an element defined in the custom registry` , ( ) => {
196
+ const { tagName, CustomElementClass} = getTestElement ( ) ;
197
+ const registry = new CustomElementRegistry ( ) ;
198
+ registry . define ( tagName , CustomElementClass ) ;
199
+ const shadowRoot = getShadowRoot ( registry ) ;
200
+
201
+ const $el = shadowRoot . createElementNS (
202
+ 'http://www.w3.org/1999/xhtml' ,
203
+ tagName
204
+ ) ;
205
+
206
+ expect ( $el ) . to . not . be . undefined ;
207
+ expect ( $el ) . to . be . instanceof ( CustomElementClass ) ;
208
+ } ) ;
209
+ } ) ;
210
+
166
211
describe ( 'innerHTML' , ( ) => {
167
212
it ( `shouldn't upgrade a defined custom element in the global registry` , ( ) => {
168
213
const { tagName, CustomElementClass} = getTestElement ( ) ;
@@ -292,6 +337,34 @@ describe('ShadowRoot', () => {
292
337
} ) ;
293
338
} ) ;
294
339
340
+ describe ( 'createElementNS' , ( ) => {
341
+ it ( 'should create a regular element' , ( ) => {
342
+ const shadowRoot = getShadowRoot ( ) ;
343
+
344
+ const $el = shadowRoot . createElementNS (
345
+ 'http://www.w3.org/1999/xhtml' ,
346
+ 'div'
347
+ ) ;
348
+
349
+ expect ( $el ) . to . not . be . undefined ;
350
+ expect ( $el ) . to . be . instanceof ( HTMLDivElement ) ;
351
+ } ) ;
352
+
353
+ it ( `should upgrade an element defined in the global registry` , ( ) => {
354
+ const { tagName, CustomElementClass} = getTestElement ( ) ;
355
+ customElements . define ( tagName , CustomElementClass ) ;
356
+ const shadowRoot = getShadowRoot ( ) ;
357
+
358
+ const $el = shadowRoot . createElementNS (
359
+ 'http://www.w3.org/1999/xhtml' ,
360
+ tagName
361
+ ) ;
362
+
363
+ expect ( $el ) . to . not . be . undefined ;
364
+ expect ( $el ) . to . be . instanceof ( CustomElementClass ) ;
365
+ } ) ;
366
+ } ) ;
367
+
295
368
describe ( 'innerHTML' , ( ) => {
296
369
it ( `shouldn't upgrade a defined custom element in a custom registry` , ( ) => {
297
370
const { tagName, CustomElementClass} = getTestElement ( ) ;
0 commit comments