Skip to content

change all existence checks to use in #732

@paulirish

Description

@paulirish

A lot of time we'll do things like

!!window.foo
elem.style.backgroundSize == ''

I think it's a good time to shift all those to use the slightly less invasive in. I've seen at least two occasions where exceptions in bad implementations would have been avoided. Additionally... Adam Barth of WebKit/Blink recommended this approach:

Nit: We'd like to encourage folks to use "requestFileSystem" in window rather than actually retrieving the property.

Good to know. Most feature detects retrieve the property now only because use of in is less common. I have encountered a few cases where in would have avoided a nasty exception from a poor implementation whereas the property access threw.

What is the functional difference between the two, just so I can educate developers?

The "in" pattern avoids allocating memory to back the property. In some cases, we'll boot up the property's subsystem when you instantiate it.

So. instead of the above we'd do..

'foo' in window
'backgroundSize' in elem.style

I dont expect this to change our results anywhere, but I'd like to verify this (at the same time as we verify the massive addTest porting didnt change anything)


2013.08.28: Edited this for clarify.

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