All files / src/NodeLike/ParentNodeLike/DocumentLike DocumentLike.ts

9.38% Statements 3/32
0% Branches 0/14
0% Functions 0/20
9.38% Lines 3/32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1022x     2x                                                                                                                                                                                                   2x
import AbstractDocumentLike       from './AbstractDocumentLike';
import IDocumentTypeLike          from '../../DocumentTypeLike/IDocumentTypeLike';
import IElementLike               from '../ElementLike/IElementLike';
import isIDocumentTypeLike        from '../../../TypeGuards/isIDocumentTypeLike';
class DocumentLike extends AbstractDocumentLike {
  get nodeType(): 9 {
    return 9;
  }
 
  get nodeName(): '#document' {
    return '#document';
  }
 
  get nodeValue(): null {
    return null;
  }
  
  get textContent(): null {
    return null;
  }
 
  get doctype(): IDocumentTypeLike | null {
    const firstChild = this.childNodes[0];
    if (isIDocumentTypeLike(firstChild)) {
      return firstChild;
    }
 
    return null;
  }
 
  get documentElement(): IElementLike | null {
    return this.firstElementChild;
  }
 
  get head(): IElementLike | null {
    const docElem = this.documentElement;
    if (docElem) {
      return docElem.querySelector('head');
    }
 
    return null;
  }
 
  get body(): IElementLike | null {
    const docElem = this.documentElement;
    if (docElem) {
      return docElem.querySelector('body');
    }
 
    return null;
  }
 
  get ownerDocument(): null {
    return null;
  }
 
  get parentNode(): null {
    return null;
  }
 
  get parentElement(): null {
    return null;
  }
 
  get previousSibling(): null {
    return null;
  }
 
  get nextSibling(): null {
    return null;
  }
 
  get childNodes(): Array<IDocumentTypeLike | IElementLike> {
    return this.__childNodes.toArray();
  }
 
  get childElementCount(): number {
    return this.__childNodes.count();
  }
 
  get children(): Array<IElementLike> {
    return this.__children.toArray();
  }
 
  get firstChild(): IDocumentTypeLike | IElementLike | null {
    return this.__childNodes.first() || null;
  }
 
  get lastChild(): IDocumentTypeLike | IElementLike | null {
    return this.__childNodes.last() || null;
  }
 
  get firstElementChild(): IElementLike | null {
    return this.__children.first() || null;
  }
 
  get lastElementChild(): IElementLike | null {
    return this.__children.last() || null;
  }
}
 
export default DocumentLike;