Skip to content

Commit 71cf828

Browse files
committed
add test for anonymous custom element
1 parent a04f2da commit 71cf828

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/pretty-format/src/__tests__/DOMElement.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,14 @@ Testing.`;
357357
customElements.define('custom-paragraph', CustomParagraphElement, {
358358
extends: 'p',
359359
});
360+
customElements.define('anonymous-element', class extends HTMLElement {});
360361

361362
const parent = document.createElement('div');
362363
parent.innerHTML = [
363364
'<custom-element></custom-element>',
364365
'<custom-extended-element></custom-extended-element>',
365366
'<p is="custom-paragraph"></p>',
367+
'<anonymous-element></anonymous-element>',
366368
].join('');
367369

368370
expect(parent).toPrettyPrintTo(
@@ -373,6 +375,7 @@ Testing.`;
373375
' <p',
374376
' is="custom-paragraph"',
375377
' />',
378+
' <anonymous-element />',
376379
'</div>',
377380
].join('\n'),
378381
);

packages/pretty-format/src/plugins/DOMElement.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ const testHasAttribute = (val: any) => {
3131
};
3232

3333
const isCustomElement = (val: any) => {
34-
const { tagName } = val
35-
return ((typeof tagName === 'string' && tagName.includes('-')) || testHasAttribute(val));
36-
}
34+
const {tagName} = val;
35+
return (
36+
(typeof tagName === 'string' && tagName.includes('-')) ||
37+
testHasAttribute(val)
38+
);
39+
};
3740

3841
const testNode = (val: any) => {
3942
const constructorName = val.constructor.name;

0 commit comments

Comments
 (0)