Question about jQuery source == on window
Asked Answered
M

1

3
data: function( elem, name, data ) {
    if ( !jQuery.acceptData( elem ) ) {
        return;
    }
    elem = elem == window ? windowData : elem;

Copied directly from the jQuery source.

Why is it not safe to use elem === window?

Why does jQuery use type coercion on the window object?

It would appear that in IE there's an issue with top

top == window // true
top === window // false
Minutes answered 31/1, 2011 at 2:0 Comment(1)
Does their documentation claim it is not safe?Arrangement
M
3

See here for why checking againts the window object with === is unsafe in IE.

I think the root cause is that IE is closely coupled with the Windows OS so you have various OS objects referenced through window and the equality check just dies. That and it just doesn't handled the global host object correctly.

Minutes answered 31/1, 2011 at 19:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.