How to use domelementtype - 10 common examples

To help you get started, we’ve selected a few domelementtype examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github broadly / css-inliner / lib / inline_rules.js View on Github external
function applyRulesRecursively(nodes, matchers) {
  for (let node of nodes) {
    const isElement = (node.type === ElementType.Tag);
    // HTML  element is only thing that can't get styled
    const isHead    = (isElement && node.name === 'head');

    if (isElement && !isHead) {
      applyRulesToElement(node, matchers);
      applyRulesRecursively(node.children, matchers);
    }
  }
}
github broadly / css-inliner / lib / inline_rules.js View on Github external
function isStylableElement(node) {
  // This selects most elements, except 
github substance / substance / dom / domUtils / lib / querying.js View on Github external
function findOne(test, elems){
  var elem = null;

  for(var i = 0, l = elems.length; i < l && !elem; i++){
    const child = elems[i]
    if(!isTag(child)){
      continue;
    } else if(test(child)){
      elem = child;
    } else if(child.childNodes.length > 0){
      elem = findOne(test, child.childNodes);
    }
  }

  return elem;
}
github arangodb / arangodb / js / node / node_modules / jshint / node_modules / htmlparser2 / node_modules / domutils / lib / querying.js View on Github external
function findOne(test, elems){
	var elem = null;

	for(var i = 0, l = elems.length; i < l && !elem; i++){
		if(!isTag(elems[i])){
			continue;
		} else if(test(elems[i])){
			elem = elems[i];
		} else if(elems[i].children.length > 0){
			elem = findOne(test, elems[i].children);
		}
	}

	return elem;
}
github zinserjan / mocha-webpack / gitbook / plugins / gitbook-plugin-anchors / node_modules / cheerio / node_modules / htmlparser2 / node_modules / domutils / lib / querying.js View on Github external
function existsOne(test, elems){
	for(var i = 0, l = elems.length; i < l; i++){
		if(
			isTag(elems[i]) && (
				test(elems[i]) || (
					elems[i].children.length > 0 &&
					existsOne(test, elems[i].children)
				)
			)
		){
			return true;
		}
	}

	return false;
}
github substance / substance / dom / domUtils / lib / querying.js View on Github external
function findAll(test, elems){
  var result = [];
  for(var i = 0, j = elems.length; i < j; i++){
    if(!isTag(elems[i])) continue;
    if(test(elems[i])) result.push(elems[i]);

    if(elems[i].childNodes.length > 0){
      result = result.concat(findAll(test, elems[i].childNodes));
    }
  }
  return result;
}
github gauravshiralkar / Intuitive-Predictions-EHR / node_modules / mysql / node_modules / readable-stream / node_modules / string_decoder / build / node_modules / cheerio / node_modules / htmlparser2 / node_modules / domhandler / index.js View on Github external
(lastTag = lastTag.children[lastTag.children.length - 1]) &&
			lastTag.type === ElementType.Text
		){
			if(normalize){
				lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
			} else {
				lastTag.data += data;
			}
		} else {
			if(normalize){
				data = data.replace(re_whitespace, " ");
			}

			this._addDomElement({
				data: data,
				type: ElementType.Text
			});
		}
	}
};
github JpEncausse / WSRNodeJS / script / vendor / cheerio / node_modules / htmlparser2 / node_modules / domhandler / index.js View on Github external
DomHandler.prototype.oncdatastart = function(){
	var element = {
		children: [{
			data: "",
			type: ElementType.Text
		}],
		type: ElementType.CDATA
	};

	this._addDomElement(element);
	this._tagStack.push(element);
};
github andrewshawcare / thoughtworks-email-signature-generator / node_modules / grunt-contrib-jshint / node_modules / jshint / node_modules / htmlparser2 / node_modules / domhandler / index.js View on Github external
var normalize = this._options.normalizeWhitespace || this._options.ignoreWhitespace;

	var lastTag;

	if(!this._tagStack.length && this.dom.length && (lastTag = this.dom[this.dom.length-1]).type === ElementType.Text){
		if(normalize){
			lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
		} else {
			lastTag.data += data;
		}
	} else {
		if(
			this._tagStack.length &&
			(lastTag = this._tagStack[this._tagStack.length - 1]) &&
			(lastTag = lastTag.children[lastTag.children.length - 1]) &&
			lastTag.type === ElementType.Text
		){
			if(normalize){
				lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
			} else {
				lastTag.data += data;
			}
		} else {
			if(normalize){
				data = data.replace(re_whitespace, " ");
			}

			this._addDomElement({
				data: data,
				type: ElementType.Text
			});
		}
github superRaytin / puzzler / node_modules / cheerio / node_modules / htmlparser2 / node_modules / domhandler / index.js View on Github external
var normalize = this._options.normalizeWhitespace || this._options.ignoreWhitespace;

	var lastTag;

	if(!this._tagStack.length && this.dom.length && (lastTag = this.dom[this.dom.length-1]).type === ElementType.Text){
		if(normalize){
			lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
		} else {
			lastTag.data += data;
		}
	} else {
		if(
			this._tagStack.length &&
			(lastTag = this._tagStack[this._tagStack.length - 1]) &&
			(lastTag = lastTag.children[lastTag.children.length - 1]) &&
			lastTag.type === ElementType.Text
		){
			if(normalize){
				lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
			} else {
				lastTag.data += data;
			}
		} else {
			if(normalize){
				data = data.replace(re_whitespace, " ");
			}

			this._addDomElement({
				data: data,
				type: ElementType.Text
			});
		}

domelementtype

all the types of nodes in htmlparser2's dom

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis