8000 [Bug] SelectAll changes array of elements passed to it by reference · Issue #847 · fb55/css-select · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Bug] SelectAll changes array of elements passed to it by reference #847
Open
@IAkumaI

Description

@IAkumaI

First of, select two elements. First - any. Second - child of the first element.
Then, just run SelectAll on this array.
Array (as any of js objects) passed by reference and css-select changes it somewhere.

Example:

const CSSselect = require('css-select');
const {parseDocument} = require('htmlparser2');

const dom = parseDocument('<div class="root"><div class="product"><h1></h1></div></div>');
const elements = CSSselect.selectAll('h1, .product', dom);
console.log(elements.length); // elements.length === 2
// elements contains both h1 AND .product (which are parent of h1)

CSSselect.selectAll('no matter', elements);
console.log(elements.length); // elements.length become 1
// elements contains only .product

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0