File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
packages/pretty-format/src/plugins Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -30,24 +30,27 @@ const testHasAttribute = (val: any) => {
30
30
}
31
31
} ;
32
32
33
+ const isCustomElement = ( val : any ) => {
34
+ const { tagName } = val
35
+ return ( typeof tagName === 'string' && tagName . includes ( '-' ) ) ||
36
+ testHasAttribute ( val ) ;
37
+ }
38
+
33
39
const testNode = ( val : any ) => {
34
40
const constructorName = val . constructor . name ;
35
- const { nodeType, tagName} = val ;
36
- const isCustomElement =
37
- ( typeof tagName === 'string' && tagName . includes ( '-' ) ) ||
38
- testHasAttribute ( val ) ;
41
+ const { nodeType} = val ;
39
42
40
43
return (
41
44
( nodeType === ELEMENT_NODE &&
42
- ( ELEMENT_REGEXP . test ( constructorName ) || isCustomElement ) ) ||
45
+ ( ELEMENT_REGEXP . test ( constructorName ) || isCustomElement ( val ) ) ) ||
43
46
( nodeType === TEXT_NODE && constructorName === 'Text' ) ||
44
47
( nodeType === COMMENT_NODE && constructorName === 'Comment' ) ||
45
48
( nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment' )
46
49
) ;
47
50
} ;
48
51
49
52
export const test : NewPlugin [ 'test' ] = ( val : any ) =>
50
- val ?. constructor && testNode ( val ) ;
53
+ ( val ?. constructor ?. name || isCustomElement ( val ) ) && testNode ( val ) ;
51
54
52
55
type HandledType = Element | Text | Comment | DocumentFragment ;
53
56
You can’t perform that action at this time.
0 commit comments