Skip to content

Commit

Permalink
Fix to attribute()
Browse files Browse the repository at this point in the history
PR: #33
  • Loading branch information
onlyfortesting authored Jun 12, 2024
1 parent d765f90 commit f1b2eaf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions surreal.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,19 @@ let $ = { // Convenience for internals.
// Remove.
if (typeof name === 'string' && value === null) {
if ($.isNodeList(e)) e.forEach(_ => { $.attribute(_, name, value) })
e.removeAttribute(name)
else e.removeAttribute(name)
return e
}
// Add / Set.
if (typeof name === 'string') {
if ($.isNodeList(e)) e.forEach(_ => { $.attribute(_, name, value) })
e.setAttribute(name, value)
else e.setAttribute(name, value)
return e
}
// Format: { "name": "value", "blah": true }
if (typeof name === 'object') {
if ($.isNodeList(e)) e.forEach(_ => { Object.entries(name).forEach(([key, val]) => { $.attribute(_, key, val) }) })
if ($.isNode(e)) Object.entries(name).forEach(([key, val]) => { $.attribute(e, key, val) })
else if ($.isNode(e)) Object.entries(name).forEach(([key, val]) => { $.attribute(e, key, val) })
return e
}
return e
Expand Down

0 comments on commit f1b2eaf

Please sign in to comment.