<commit_before>/// <reference path="./jsdom.d.ts" />

import {implementation as TextImpl} from 'jsdom/lib/jsdom/living/nodes/Text-impl';
import {interface as Text} from 'jsdom/lib/jsdom/living/generated/Text';
import * as NODE_TYPE from 'jsdom/lib/jsdom/living/node-type';
import {domSymbolTree} from 'jsdom/lib/jsdom/living/helpers/internal-constants';

export function polyfillWholeText() {
  function wholeText() {
    let wholeText = this.textContent;
    let next;
    let current = this;
    while ((next = domSymbolTree.previousSibling(current)) && next.nodeType === NODE_TYPE.TEXT_NODE) {
      wholeText = next.textContent + wholeText;
      current = next;
    }
    current = this;
    while ((next = domSymbolTree.nextSibling(current)) && next.nodeType === NODE_TYPE.TEXT_NODE) {
      wholeText += next.textContent;
      current = next;
    }
    return wholeText;
  };
  const implementationsToPolyfill = [TextImpl.prototype, Text.prototype];
  implementationsToPolyfill.forEach(implementation => {
    const definedProperties = Object.getOwnPropertyNames(implementation);
    if (definedProperties.indexOf('wholeText') >= 0) return;
    Object.defineProperty(implementation, 'wholeText', {
      get: wholeText,
      enumerable: true,
      configurable: true
    });
  })<commit_msg>fix(jsdom-whole-text): use hasOwnProperty<commit_after>/// <reference path="./jsdom.d.ts" />

import {implementation as TextImpl} from 'jsdom/lib/jsdom/living/nodes/Text-impl';
import {interface as Text} from 'jsdom/lib/jsdom/living/generated/Text';
import * as NODE_TYPE from 'jsdom/lib/jsdom/living/node-type';
import {domSymbolTree} from 'jsdom/lib/jsdom/living/helpers/internal-constants';

export function polyfillWholeText() {
  function wholeText() {
    let wholeText = this.textContent;
    let next;
    let current = this;
    while ((next = domSymbolTree.previousSibling(current)) && next.nodeType === NODE_TYPE.TEXT_NODE) {
      wholeText = next.textContent + wholeText;
      current = next;
    }
    current = this;
    while ((next = domSymbolTree.nextSibling(current)) && next.nodeType === NODE_TYPE.TEXT_NODE) {
      wholeText += next.textContent;
      current = next;
    }
    return wholeText;
  };
  const implementationsToPolyfill = [TextImpl.prototype, Text.prototype] as Array<Object>;
  implementationsToPolyfill.forEach(implementation => {
    if (implementation.hasOwnProperty('wholeText')) return;
    Object.defineProperty(implementation, 'wholeText', {
      get: wholeText,
      enumerable: true,
      configurable: true
    });
  })
{'fraction_non_alphanumeric': 0.12752721617418353, 'fraction_numerical': 0.00038880248833592535, 'mean_word_length': 3.9671814671814674, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1863400', 'n_tokens_mistral': 792, 'n_tokens_neox': 778, 'n_words': 160}