Sha256: b24f59659379aa2622d2e68bc0490cb5626bfb972daf70cadef027fd02ece124

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

"use strict";

const CharacterDataImpl = require("./CharacterData-impl").implementation;

const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const DOMException = require("../../web-idl/DOMException");
const NODE_TYPE = require("../node-type");

class TextImpl extends CharacterDataImpl {
  constructor(args, privateData) {
    super(args, privateData);

    this.nodeType = NODE_TYPE.TEXT_NODE;
  }

  splitText(offset) {
    offset >>>= 0;

    const length = this.length;

    if (offset > length) {
      throw new DOMException(DOMException.INDEX_SIZE_ERR);
    }

    const count = length - offset;
    const newData = this.substringData(offset, count);

    const newNode = this._ownerDocument.createTextNode(newData);

    const parent = domSymbolTree.parent(this);

    if (parent !== null) {
      parent.insertBefore(newNode, this.nextSibling);
    }

    this.replaceData(offset, count, "");

    return newNode;

    // TODO: range stuff
  }

  // TODO: wholeText property
}

module.exports = {
  implementation: TextImpl
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
select_all-rails-0.3.1 node_modules/jsdom/lib/jsdom/living/nodes/Text-impl.js