File tree Expand file tree Collapse file tree
packages/pretty-format/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6868- ` [jest-worker] ` Handle ` ERR_IPC_CHANNEL_CLOSED ` errors properly ([ #11143 ] ( https://github.com/facebook/jest/pull/11143 ) )
6969- ` [pretty-format] ` [ ** BREAKING** ] Convert to ES Modules ([ #10515 ] ( https://github.com/facebook/jest/pull/10515 ) )
7070- ` [pretty-format] ` Only call ` hasAttribute ` if it's a function ([ #11000 ] ( https://github.com/facebook/jest/pull/11000 ) )
71+ - ` [pretty-format] ` Handle jsdom attributes properly ([ #11189 ] ( https://github.com/facebook/jest/pull/11189 ) )
7172
7273### Chore & Maintenance
7374
Original file line number Diff line number Diff line change @@ -582,4 +582,9 @@ Testing.`;
582582 ] . join ( '\n' ) ,
583583 ) ;
584584 } ) ;
585+
586+ it ( 'handles jsdom attributes properly' , ( ) => {
587+ const attributes = require ( 'jsdom/lib/jsdom/living/attributes' ) ;
588+ expect ( DOMElement . test ( attributes ) ) . toBe ( false ) ;
589+ } ) ;
585590} ) ;
Original file line number Diff line number Diff line change @@ -22,12 +22,20 @@ const FRAGMENT_NODE = 11;
2222
2323const ELEMENT_REGEXP = / ^ ( ( H T M L | S V G ) \w * ) ? E l e m e n t $ / ;
2424
25+ const testHasAttribute = ( val : any ) => {
26+ try {
27+ return typeof val . hasAttribute === 'function' && val . hasAttribute ( 'is' ) ;
28+ } catch {
29+ return false ;
30+ }
31+ } ;
32+
2533const testNode = ( val : any ) => {
2634 const constructorName = val . constructor . name ;
2735 const { nodeType, tagName} = val ;
2836 const isCustomElement =
2937 ( typeof tagName === 'string' && tagName . includes ( '-' ) ) ||
30- ( typeof val . hasAttribute === 'function' && val . hasAttribute ( 'is' ) ) ;
38+ testHasAttribute ( val ) ;
3139
3240 return (
3341 ( nodeType === ELEMENT_NODE &&
You can’t perform that action at this time.
0 commit comments