feat(core): Added the Attributes.setIfUnset() method
This commit is contained in:
parent
567046f52c
commit
2eb7a23750
4 changed files with 58 additions and 5 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue