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) => {
3030 }
3131} ;
3232
33+ const isCustomElement = ( val : any ) => {
34+ const { tagName } = val
35+ return ( typeof tagName === 'string' && tagName . includes ( '-' ) ) ||
36+ testHasAttribute ( val ) ;
37+ }
38+
3339const testNode = ( val : any ) => {
3440 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 ;
3942
4043 return (
4144 ( nodeType === ELEMENT_NODE &&
42- ( ELEMENT_REGEXP . test ( constructorName ) || isCustomElement ) ) ||
45+ ( ELEMENT_REGEXP . test ( constructorName ) || isCustomElement ( val ) ) ) ||
4346 ( nodeType === TEXT_NODE && constructorName === 'Text' ) ||
4447 ( nodeType === COMMENT_NODE && constructorName === 'Comment' ) ||
4548 ( nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment' )
4649 ) ;
4750} ;
4851
4952export const test : NewPlugin [ 'test' ] = ( val : any ) =>
50- val ?. constructor && testNode ( val ) ;
53+ ( val ?. constructor ?. name || isCustomElement ( val ) ) && testNode ( val ) ;
5154
5255type HandledType = Element | Text | Comment | DocumentFragment ;
5356
You can’t perform that action at this time.
0 commit comments