How to use the domelementtype.isTag function in domelementtype

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 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 substance / substance / dom / _domSerializer.js View on Github external
function render(dom, opts) {
  if (!Array.isArray(dom)) dom = [dom]
  opts = opts || {}

  let output = []

  for(var i = 0; i < dom.length; i++){
    let elem = dom[i]

    if (elem.type === 'root') {
      output.push(render(elem.childNodes, opts))
    } else if (ElementType.isTag(elem)) {
      output.push(renderTag(elem, opts))
    } else if (elem.type === ElementType.Directive) {
      output.push(renderDirective(elem))
    } else if (elem.type === ElementType.Comment) {
      output.push(renderComment(elem))
    } else if (elem.type === ElementType.CDATA) {
      output.push(renderCdata(elem))
    } else {
      output.push(renderText(elem, opts))
    }
  }

  return output.join('')
}
github csxiaoyaojianxian / JavaScriptStudy / 09-Tools / 01-webpack / node_modules / domhandler / index.js View on Github external
var lastTag = this._tagStack[this._tagStack.length - 1];

	var element = {
		type: name === "script" ? ElementType.Script : name === "style" ? ElementType.Style : ElementType.Tag,
		name: name,
		attribs: attribs,
		children: [],
		prev: null,
		next: null,
		parent: lastTag || null
	};

	if(lastTag){
		var idx = lastTag.children.length;
		while(idx > 0){
			if(ElementType.isTag(lastTag.children[--idx])){
				element.prev = lastTag.children[idx];
				lastTag.children[idx].next = element;
				break;
			}
		}
		lastTag.children.push(element);
	} else {
		this.dom.push(element);
	}

	this._tagStack.push(element);
};
github kapetan / repaint / source / layout.js View on Github external
nodes.forEach(function(node) {
		var box;

		if(ElementType.isTag(node)) {
			var style = node.style;
			var display = style.display;

			if(None.is(display)) {
				return;
			} else if(node.name === 'img') {
				var image = node.image;

				if(Block.is(display)) box = new ImageBox.Block(parent, style, image);
				else box = new ImageBox.Inline(parent, style, image);
			} else if(Inline.is(display)) {
				box = new InlineBox(parent, style);
			} else if(Block.is(display)) {
				box = new BlockBox(parent, style);
			} else if(LineBreak.is(display)) {
				box = new LineBreakBox(parent, style);
github kuhnza / cheerio-repl / node_modules / cheerio / node_modules / htmlparser2 / node_modules / domhandler / index.js View on Github external
var lastTag = this._tagStack[this._tagStack.length - 1];

	var element = {
		type: name === "script" ? ElementType.Script : name === "style" ? ElementType.Style : ElementType.Tag,
		name: name,
		attribs: attribs,
		children: [],
		prev: null,
		next: null,
		parent: lastTag || null
	};

	if(lastTag){
		var idx = lastTag.children.length;
		while(idx > 0){
			if(ElementType.isTag(lastTag.children[--idx])){
				element.prev = lastTag.children[idx];
				lastTag.children[idx].next = element;
				break;
			}
		}
		lastTag.children.push(element);
	} else {
		this.dom.push(element);
	}

	this._tagStack.push(element);
};

domelementtype

all the types of nodes in htmlparser2's dom

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis