How to use the htmlparser2.DomUtils.getElementsByTagName function in htmlparser2

To help you get started, we’ve selected a few htmlparser2 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 fb55 / css-select / test / nwmatcher / scotch.js View on Github external
"[foo]": function() {
            var body = DomUtils.getElementsByTagName("body", document, true, 1)[0];
            assertEquivalent(select("[href]", body), select("a[href]", body));
            assertEquivalent(select("[class~=internal]"), select('a[class~="internal"]'));
            assertEquivalent(select("[id]"), select("*[id]"));
            assertEquivalent(select("[type=radio]"), getById("checked_radio", "unchecked_radio"));
            assertEquivalent(select("[type=checkbox]"), select("*[type=checkbox]"));
            assertEquivalent(select("[title]"), getById("with_title", "commaParent"));
            assertEquivalent(select("#troubleForm [type=radio]"), select("#troubleForm *[type=radio]"));
            assertEquivalent(select("#troubleForm [type]"), select("#troubleForm *[type]"));
        },
        "E[foo]": function() {
github fb55 / css-select / test / qwery / index.js View on Github external
":last-child": function() {
            var all = DomUtils.getElementsByTagName("div", pseudos);
            expect(CSSselect("#pseudos div:last-child", document)[0]).to.be(all[all.length - 1]); //found last child
            expect(CSSselect("#pseudos div:last-child", document)).to.have.length(1); //found only 1
        },
github fb55 / css-select / test / qwery / index.js View on Github external
":first-of-type": function() {
            expect(CSSselect("#pseudos a:first-of-type", document)[0]).to.be(
                DomUtils.getElementsByTagName("a", pseudos)[0]
            ); //found first a element
            expect(CSSselect("#pseudos a:first-of-type", document)).to.have.length(1); //found only 1
        },
github fb55 / css-select / test / qwery / index.js View on Github external
":nth-child(odd|even|x)": function() {
            var second = DomUtils.getElementsByTagName("div", pseudos)[1];
            expect(CSSselect("#pseudos :nth-child(odd)", document)).to.have.length(4); //found 4 odd elements
            expect(CSSselect("#pseudos div:nth-child(odd)", document)).to.have.length(3); //found 3 odd elements with div tag
            expect(CSSselect("#pseudos div:nth-child(even)", document)).to.have.length(3); //found 3 even elements with div tag
            expect(CSSselect("#pseudos div:nth-child(2)", document)[0]).to.be(second); //found 2nd nth-child of pseudos
        },
github fb55 / css-select / test / nwmatcher / scotch.js View on Github external
E: function() {
            //Type selector
            var results = [],
                index = 0,
                nodes = DomUtils.getElementsByTagName("li", document);
            while ((results[index] = nodes[index++])) {}
            results.length--;
            assertEquivalent(select("li"), results);
            assertEqual(select("strong", getById("fixtures"))[0], getById("strong"));
            assertEquivalent(select("nonexistent"), []);
        },
        "#id": function() {