File tree 2 files changed +9
-1
lines changed
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -298,7 +298,10 @@ export default class Node extends EventTarget implements INode {
298
298
* @param otherNode Node to test with.
299
299
* @returns "true" if this node contains the other node.
300
300
*/
301
- public contains ( otherNode : INode ) : boolean {
301
+ public contains ( otherNode : INode | undefined ) : boolean {
302
+ if ( otherNode === undefined ) {
303
+ return false ;
304
+ }
302
305
return NodeUtility . isInclusiveAncestor ( this , otherNode ) ;
303
306
}
304
307
Original file line number Diff line number Diff line change @@ -330,6 +330,11 @@ describe('Node', () => {
330
330
331
331
expect ( div . contains ( null ) ) . toBe ( false ) ;
332
332
} ) ;
333
+ it ( 'Returns "false" if match node is undefined.' , ( ) => {
334
+ const div = document . createElement ( 'div' ) ;
335
+
336
+ expect ( div . contains ( undefined ) ) . toBe ( false ) ;
337
+ } ) ;
333
338
} ) ;
334
339
335
340
describe ( 'getRootNode()' , ( ) => {
You can’t perform that action at this time.
0 commit comments