Brian
Brian

Reputation: 49

object.style.hasOwnProperty('MozTransform') returns false?

When using "hasOwnProperty" to check for the existence of a style property, Firefox will return false while Chrome and IE are behaving the way I'd expect and will return true using their respective transform prefix. If, however, I use the "in" operator, it works just fine.

object = document.getElementById('myThing');
console.log(object.style.hasOwnProperty('MozTransform') // False
console.log("MozTransform" in object.style); // True

I was wondering if anyone could explain why hasOwnProperty is working so differently in Firefox.

Upvotes: 1

Views: 276

Answers (1)

Boris Zbarsky
Boris Zbarsky

Reputation: 35074

Per spec, properties like this are own properties of the prototype, not of the object itself. Hence the behavior you see in Firefox.

Upvotes: 1

Related Questions