import { MockElement , MockHTMLElement } from './node' ; import { NODE_NAMES , NODE_TYPES } from './constants' ; import { getElementById } from './document' ; export class MockDocumentFragment extends MockHTMLElement { constructor ( ownerDocument ) { super ( ownerDocument , null ) ; this . nodeName = NODE_NAMES . DOCUMENT_FRAGMENT_NODE ; this . nodeType = NODE_TYPES . DOCUMENT_FRAGMENT_NODE ; } getElementById ( id ) { return getElementById ( this , id ) ; } override cloneNode ( deep ? ) { const cloned = new MockDocumentFragment ( null ) ; if ( deep ) { for ( let i = 0 , ii = this . childNodes . length ; i < ii ; i ++ ) { const childNode = this . childNodes [ i ] ; if ( childNode . nodeType === NODE_TYPES . ELEMENT_NODE || childNode . nodeType === NODE_TYPES . TEXT_NODE || childNode . nodeType === NODE_TYPES . COMMENT_NODE ) { const clonedChildNode = this . childNodes [ i ] . cloneNode ( true ) ; cloned . appendChild ( clonedChildNode ) ; } } } return cloned ; } }