Skip to content

possibly simpler implementation? #1

@bboyle

Description

@bboyle

Might be simpler to clone the element, then manipulate the cloned tree and simply return .text() at the end.
No recursion, no lengthy string concatenation. Need to test which algorithm performs faster (try http://jsperf.com/)

        var clone = this.clone();

        clone.find( 'script, noscript' ).remove();
        clone.find( 'img' ).map(function() {
            return this.alt;
        });
        clone.find( 'input' ).map(function() {
            return this.value;
        });

        return clone.text();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions