1
0
Fork 0

feat(core): Added the Attributes.setIfUnset() method

This commit is contained in:
Joost De Cock 2021-11-21 17:18:10 +01:00
parent 567046f52c
commit 2eb7a23750
4 changed files with 58 additions and 5 deletions

View file

@ -19,6 +19,13 @@ Attributes.prototype.set = function (name, value) {
return this
}
/** Sets an attribute, but only if it's not currently set */
Attributes.prototype.setIfUnset = function (name, value) {
if (typeof this.list[name] === 'undefined') this.list[name] = [value]
return this
}
/** Removes an attribute */
Attributes.prototype.remove = function (name) {
delete this.list[name]