Sha256: c4d8b15d24af2e9366805dbf1f908c911ea5466f1965900d8d6c48f3954c4912

Contents?: true

Size: 1.88 KB

Versions: 26

Compression:

Stored size: 1.88 KB

Contents

"use strict";
const nodeTypes = require("../node-type");
const { domSymbolTree } = require("../helpers/internal-constants");
// Serialization only requires a subset of the tree adapter interface.

// Tree traversing
exports.getFirstChild = node => node.firstChild;

exports.getChildNodes = node => domSymbolTree.childrenToArray(node);

exports.getParentNode = node => node.parentNode;

exports.getAttrList = element => {
  const attributeList = [...element._attributeList];

  if (element._isValue && attributeList.every(attr => attr.name !== "is")) {
    attributeList.unshift({
      name: "is",
      namespace: null,
      prefix: null,
      value: element._isValue
    });
  }

  return attributeList;
};

// Node data
exports.getTagName = element => element._qualifiedName; // https://github.com/inikulin/parse5/issues/231

exports.getNamespaceURI = element => element.namespaceURI;

exports.getTextNodeContent = exports.getCommentNodeContent = node => node.data;

exports.getDocumentTypeNodeName = node => node.name;

exports.getDocumentTypeNodePublicId = node => node.publicId;

exports.getDocumentTypeNodeSystemId = node => node.systemId;

exports.getTemplateContent = templateElement => templateElement._templateContents;

exports.getDocumentMode = document => document._mode;

// Node types
exports.isTextNode = node => node.nodeType === nodeTypes.TEXT_NODE;

exports.isCommentNode = node => node.nodeType === nodeTypes.COMMENT_NODE;

exports.isDocumentTypeNode = node => node.nodeType === nodeTypes.DOCUMENT_TYPE_NODE;

exports.isElementNode = node => node.nodeType === nodeTypes.ELEMENT_NODE;

// Source code location
exports.setNodeSourceCodeLocation = (node, location) => {
  node.sourceCodeLocation = location;
};

exports.getNodeSourceCodeLocation = node => node.sourceCodeLocation;

exports.updateNodeSourceCodeLocation = (node, endLocation) => {
  Object.assign(node.sourceCodeLocation, endLocation);
};

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js