介绍
elem.hidden是一个允许隐藏元素并检测它们是否被隐藏的新属性。
浏览器支持不是很好,所以我想对其进行填充。如果我要填充这个属性,那么在通过elem.style.
Shim 的简单实现
Object.defineProperty(HTMLElement.prototype, "hidden", {
get: function get() {
return this.style.<???>;
},
set: function set(v) {
this.style.<???> = v ? <???> : <???>
},
configurable: true
});
问题
- 它应该设置
elem.style.display为"none"or<original value>吗? - 它应该设置
elem.style.visibility为"hidden"or"visible"吗?