Skip to content

Commit

Permalink
Move hasAttribute & co to Element
Browse files Browse the repository at this point in the history
  • Loading branch information
lauriro committed Dec 31, 2022
1 parent a84c3cd commit 2f090ba
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions index.js
Expand Up @@ -198,6 +198,23 @@ var boolAttrs = {
get previousElementSibling() {
return getSibling(this, -1, 1)
},
hasAttribute: function(name) {
name = escapeAttributeName(name)
return name != "style" ? hasOwn.call(this, name) :
!!(this.styleMap && Object.keys(this.styleMap).length)
},
getAttribute: function(name) {
name = escapeAttributeName(name)
return this.hasAttribute(name) ? "" + this[name] : null
},
setAttribute: function(name, value) {
this[escapeAttributeName(name)] = "" + value
},
removeAttribute: function(name) {
name = escapeAttributeName(name)
this[name] = ""
delete this[name]
},
getElementById: function(id) {
return selector.find(this, "#" + id, 1)
},
Expand Down Expand Up @@ -304,26 +321,9 @@ extendNode(HTMLElement, Element, {
localName: null,
tagName: null,
styleMap: null,
hasAttribute: function(name) {
name = escapeAttributeName(name)
return name != "style" ? hasOwn.call(this, name) :
!!(this.styleMap && Object.keys(this.styleMap).length)
},
getAttribute: function(name) {
name = escapeAttributeName(name)
return this.hasAttribute(name) ? "" + this[name] : null
},
setAttribute: function(name, value) {
this[escapeAttributeName(name)] = "" + value
},
setAttributeNS: function (namespace, name, value) {
this.setAttribute(name, value)
},
removeAttribute: function(name) {
name = escapeAttributeName(name)
this[name] = ""
delete this[name]
},
focus: function() {
this.ownerDocument.activeElement = this
},
Expand Down

0 comments on commit 2f090ba

Please sign in to comment.