About HTML5's new feature placeholder on Firefox
-
29-10-2019 - |
Question
On Firefox:
console.log(document.createElement('input').placeholder === ''); // true
console.log(document.createElement('input').hasOwnProperty('placeholder')); // false
I think the 2nd line codes should return true
just like what you can see on Chrome. But I get false
. Why?
Thank you!
Solution
The spec defines the JS property as being on the prototype, not on the object itself. Chrome gets this wrong for all DOM properties; it's a longstanding bug in Chrome.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow