All files / src/NodeLike/CharacterDataLike/CommentLike CommentLike.ts

6.52% Statements 3/46
0% Branches 0/12
0% Functions 0/19
6.52% Lines 3/46
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 1292x         2x                                                                                                                                                                                                                                                     2x
import AbstractCommentLike           from './AbstractCommentLike';
import IChildNodeLike                from '../../IChildNodeLike';
import IDocumentLike                 from '../../ParentNodeLike/DocumentLike/IDocumentLike';
import IElementLike                  from '../../ParentNodeLike/ElementLike/IElementLike';
import INonDocumentTypeChildNodeLike from '../../INonDocumentTypeChildNodeLike';
import isIElementLike                from '../../../TypeGuards/isIElementLike';
class CommentLike extends AbstractCommentLike {
  get nodeType(): 8 {
    return 8;
  }
 
  get nodeName(): '#comment' {
    return '#comment';
  }
 
  get data(): string {
    return this.__data;
  }
 
  set data(data: string) {
    this.__data = data;
  }
 
  get textContent(): string {
    return this.__data;
  }
 
  set textContent(textContent: string) {
    this.__data = textContent;
  }
 
  get nodeValue(): string {
    return this.__data;
  }
 
  set nodeValue(value: string) {
    this.__data = value;
  }
 
  get length(): number {
    return this.__data.length;
  }
 
  get ownerDocument(): IDocumentLike {
    return this.__ownerDocument;
  }
 
  get parentNode(): IElementLike | null {
    return this.__parentNode;
  }
 
  get parentElement(): IElementLike | null {
    return this.__parentNode;
  }
 
  get previousSibling(): INonDocumentTypeChildNodeLike | null {
    return this.__previousSibling;
  }
 
  get nextSibling(): INonDocumentTypeChildNodeLike | null {
    return this.__nextSibling;
  }
  
  get previousElementSibling(): IElementLike | null {
    /* An element with no parent cannot have siblings. */
    if (!this.__parentNode) {
      return null;
    }
 
    let node: IChildNodeLike | null = this.previousSibling;
    let counter = 0;
    const length = this.__parentNode.childNodes.length;
    while (node) {
      if (counter > length) {
        throw new Error('Possible infinite loop detected. A previousSibling ' +
                        'property may be misset.');
      }
 
      if (isIElementLike(node)) {
        return node;
      }
      
      node = node.previousSibling;
      counter += 1;
    }
 
    return null;
  }
  
  get nextElementSibling(): IElementLike | null {
    /* An element with no parent cannot have siblings. */
    if (!this.__parentNode) {
      return null;
    }
 
    let node = this.nextSibling;
    let counter = 0;
    const length = this.__parentNode.childNodes.length;
    while (node) {
      if (counter > length) {
        throw new Error('Possible infinite loop detected. A previousSibling ' +
                        'property may be misset.');
      }
 
      if (isIElementLike(node)) {
        return node;
      }
 
      node = node.nextSibling;
      counter += 1;
    }
 
    return null;
  }
 
  get childNodes(): Array<any> {
    return [];
  }
 
  get firstChild(): null {
    return null;
  }
 
  get lastChild(): null {
    return null;
  }
}
 
export default CommentLike;