Skip to content

Filter plugin select2 Uncaught TypeError: element.getAttribute is not a function #924

Closed
@rickdubiel

Description

@rickdubiel

I've recently upgraded from v2.5.2 to v2.6.0 and ran across a tiny issue with the $.parseHTML update when using the select2 plugin. I believe this issue addresses that update:

#905

I narrowed it down to the ruleValueSelect template leaving a single space at the beginning of the template and then $.parseHtml parses that out as an individual array item. When select2 tries to an apply an id to that item by using getAttribute the error occurs. See below:

image

The jQuery docs recommended using jQuery.trim in order to prevent trailing/leading whitespace from being converted to text nodes. That indeed did resolve the issue. Here's a PR with the change:

#923

Here's a fiddle with the issue:

https://jsfiddle.net/6qyLvhpb/1/

Just need to make a selection and watch the console to see the error.

Thanks!

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