This project is archived and is in readonly mode.

#684 ✓resolved
Oskar Krawczyk

IE problem when extending Selectors.Pseudo

Reported by Oskar Krawczyk | June 11th, 2009 @ 11:04 AM | in 2.0 (closed)

Howdy,

Here's the case: I'm adding a custom pseudo-selector by doing:

$extend(Selectors.Pseudo, {
    external: function() {
        return (!this.get('href').contains(window.location.host.toString()) && !this.get('href').contains('#'));
    }
});

This will fail in IE, by throwing "this is not an object". To fix this I need to wrap this in $(this), fair enough. But is this intentional? I understand some of this stuff was left out intentionally for performance reasons, but I think in this particular case, "this" should be extended auto-magically.

Regards,
Oskar

Ps. Extending Selectors.Pseudo, FTW!

Comments and changes to this ticket

  • Valerio

    Valerio June 11th, 2009 @ 11:37 AM

    • State changed from “new” to “resolved”

    Yes, this is intended.
    Extending every element it "walks" is not an option in the selector engine. Wrapping $ (document.id()) should be easy enough as a "workaround" in these situations.

    However, if the custom pseudos need to be very performant, I suggest to write them in plain JS (regarding element methods), or atleast use Element generics:

    return (!Element.get(this, 'href').contains(window.location.host.toString()) && !Element.get(this, 'href').contains('#'));
    

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Pages