UNPKG

substance

Version:

Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).

53 lines (43 loc) 1.09 kB
import DomUtils from '../dom/domutils' import { getChildren, getParent } from './documentHelpers' import hasOwnProperty from '../util/hasOwnProperty' export default class DocumentNodeSelectAdapter extends DomUtils.DomUtils { // we only have nodes which correspond to DOM elements isTag () { return true } getChildren (node) { return getChildren(node) } getParent (node) { return getParent(node) } getAttributeValue (node, name) { return node[name] } getAttributes (node) { // TODO: how could be attribute selectors be implemented? // Probably only properties with primitive type return ['id', node.id] } hasAttrib (node, name) { if (name === 'id') { return true } else { return hasOwnProperty(node, name) } } getName (node) { return node.type } getNameWithoutNS (node) { return this.getName(node) } getText (node) { // TODO: do we really need this. Assuming that it is not important for css-select if (node.isText()) { return node.getText() } return '' } }