UNPKG

svgdom

Version:

Straightforward DOM implementation for SVG, HTML and XML

41 lines (31 loc) 959 B
import { Node } from './Node.js' import { mixin } from '../utils/objectCreationUtils.js' import { NonDocumentTypeChildNode } from './mixins/NonDocumentTypeChildNode.js' import { ChildNode } from './mixins/ChildNode.js' export class CharacterData extends Node { constructor (name, props) { super(name, props) this.data = this.nodeValue } appendData (data) { this.data += data } deleteData (offset, count) { this.data = this.data.slice(0, offset) + this.data.slice(0, offset + count) } insertData (offset, data) { this.data = this.data.slice(0, offset) + data + this.data.slice(offset) } replaceData (offset, count, data) { this.deleteData(offset, count) this.insertData(offset, data) } substringData (offset, count) { this.data = this.data.substr(offset, count) } get length () { return this.data.length } } mixin(NonDocumentTypeChildNode, CharacterData) mixin(ChildNode, CharacterData)