Skip to content

#20 breaks subclassing jQuery #36

@laughinghan

Description

@laughinghan

Unclear whether this is worth "fixing" (whatever that means), but I think it's worth at least discussing even if we decide just to document a workaround.

If you subclass jQuery with Pjs, many methods that aren't supposed to mutate this, like .appendTo(), will add elements to this: http://jsbin.com/faxifed/edit?html,console,output

This was causing exponentially growing jQuery sets in MathQuill (mathquill/mathquill#629).

This is because jQuery internally calls this.constructor() which normally creates a whole new jQuery object, but for Pjs subclasses starting with #20 on v5.0.0 just returns this: https://github.com/jquery/jquery/blob/305f193aa57014dc7d8fa0739a3fefd47166cd44/src/core.js#L72-L84

Thanks @jwmerrill!

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