How to use the domhandler.prototype function in domhandler

To help you get started, we’ve selected a few domhandler 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 2youyou2 / raphael-example / assets / raphael / component / optional / R.svg.js View on Github external
}

        var svg = $('svg')[0];
        parseNode(svg, this);

        this.flipY = true;
    },
};


// hack for jsb, not use __proto__
var DomHandler = require('domhandler');
var NodePrototype = require("domhandler/lib/node");
var ElementPrototype = require("domhandler/lib/element");

DomHandler.prototype._addDomElement = function(element){
    var parent = this._tagStack[this._tagStack.length - 1];
    var siblings = parent ? parent.children : this.dom;
    var previousSibling = siblings[siblings.length - 1];

    element.next = null;

    if(this._options.withStartIndices){
        element.startIndex = this._parser.startIndex;
    }

    if (this._options.withDomLvl1) {

        var originElement = element;
        element = Object.create(element.type === "tag" ? ElementPrototype : NodePrototype);
        for (var k in originElement) {
            element[k] = originElement[k];
github fb55 / node-cornet / index.js View on Github external
var DomHandler = require("domhandler"),
    DomUtils = require("domutils"),
    CSSselect = require("CSSselect");

function Handler(options){
	if(!(this instanceof Handler)) return new Handler(options);
	var that = this;
	DomHandler.call(this, function(e, dom){
		that.emit("dom", dom);
	}, options, function(elem){
		that.emit("element", elem);
	});
}

require("util").inherits(Handler, require("events").EventEmitter);
Object.getOwnPropertyNames(DomHandler.prototype).forEach(function(name){
	Handler.prototype[name] = DomHandler.prototype[name];
});

Handler.prototype.select = function(selector, cb){
	if(typeof selector === "string"){
		selector = CSSselect.parse(selector);
	}
	function onElem(elem){
		if(selector(elem)) cb(elem);
	}
	this.on("element", onElem);
	return onElem;
};

Handler.prototype.remove = function(selector){
	return this.select(selector, DomUtils.removeElement);
github fb55 / htmlparser2 / lib / FeedHandler.js View on Github external
tmp;

                item = item.children;

                addConditionally(entry, "id", "guid", item);
                addConditionally(entry, "title", "title", item);
                addConditionally(entry, "link", "link", item);
                addConditionally(entry, "description", "description", item);
                if ((tmp = fetch("pubDate", item)))
                    entry.pubDate = new Date(tmp);
                return entry;
            });
        }
    }
    this.dom = feed;
    DomHandler.prototype._handleCallback.call(
        this,
        feedRoot ? null : Error("couldn't find root of feed")
    );
};
github Rainbox-dev / DuAEF_Duik / Release / Duik-API / src-doc / tui-jsdoc-template / node_modules / htmlparser2 / lib / FeedHandler.js View on Github external
tmp;

                item = item.children;

                addConditionally(entry, "id", "guid", item);
                addConditionally(entry, "title", "title", item);
                addConditionally(entry, "link", "link", item);
                addConditionally(entry, "description", "description", item);
                if ((tmp = fetch("pubDate", item)))
                    entry.pubDate = new Date(tmp);
                return entry;
            });
        }
    }
    this.dom = feed;
    DomHandler.prototype._handleCallback.call(
        this,
        feedRoot ? null : Error("couldn't find root of feed")
    );
};
github fb55 / node-cornet / index.js View on Github external
Object.getOwnPropertyNames(DomHandler.prototype).forEach(function(name){
	Handler.prototype[name] = DomHandler.prototype[name];
});

domhandler

Handler for htmlparser2 that turns pages into a dom

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

78 / 100
Full package analysis