Open
Bug 1476680
Opened 6 years ago
Updated 2 years ago
Update xulStore.persist to automatically remove a value if the attr is missing
Categories
(Toolkit :: General, enhancement, P3)
Toolkit
General
Tracking
()
NEW
People
(Reporter: bgrins, Unassigned)
References
Details
See https://bugzilla.mozilla.org/show_bug.cgi?id=1476030#c15. We are porting over some behavior from document.persist into xulStore.persist that is a bit inconsistent. It will remove a value from the store, but only if it was already set with a non empty value. So:
```
node.setAttribute("foo", "bar");
document.persist(node.id, "foo");
node.removeAttribute("foo");
document.persist(node.id, "foo");
```
Will ultimately remove "foo" from the store, but:
```
node.removeAttribute("foo");
document.persist(node.id, "foo");
```
Would write "foo" into the store with an empty value.
This leads to code like https://dxr.mozilla.org/mozilla-central/rev/085cdfb90903d4985f0de1dc7786522d9fb45596/browser/base/content/browser-sidebar.js#81-85:
```
if (this._box.hasAttribute("positionend")) {
xulStore.persist(this._box, "positionend");
} else {
xulStore.removeValue(document.documentURI, "sidebar-box", "positionend");
}
```
Which could be rewritten (if we adopt this proposed change) to:
```
xulStore.persist(this._box, "positionend");
```
We'll need to audit current callers to xulStore.persist to ensure they aren't relying on the current behavior.
Updated•6 years ago
|
Priority: -- → P3
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•