mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Avoid throwing with invalid keys/paths. Fixes #3018.
This commit is contained in:
parent
cfa6d51479
commit
5076ee0b88
@ -50,9 +50,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
},
|
||||
|
||||
removeKey: function(key) {
|
||||
key = this._parseKey(key);
|
||||
this._removeFromMap(this.store[key]);
|
||||
delete this.store[key];
|
||||
if (key = this._parseKey(key)) {
|
||||
this._removeFromMap(this.store[key]);
|
||||
delete this.store[key];
|
||||
}
|
||||
},
|
||||
|
||||
_removeFromMap: function(item) {
|
||||
@ -88,29 +89,30 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
},
|
||||
|
||||
_parseKey: function(key) {
|
||||
if (key[0] == '#') {
|
||||
if (key && key[0] == '#') {
|
||||
return key.slice(1);
|
||||
}
|
||||
throw new Error('unexpected key ' + key);
|
||||
},
|
||||
|
||||
setItem: function(key, item) {
|
||||
key = this._parseKey(key);
|
||||
var old = this.store[key];
|
||||
if (old) {
|
||||
this._removeFromMap(old);
|
||||
if (key = this._parseKey(key)) {
|
||||
var old = this.store[key];
|
||||
if (old) {
|
||||
this._removeFromMap(old);
|
||||
}
|
||||
if (item && typeof item == 'object') {
|
||||
this.omap.set(item, key);
|
||||
} else {
|
||||
this.pmap[item] = key;
|
||||
}
|
||||
this.store[key] = item;
|
||||
}
|
||||
if (item && typeof item == 'object') {
|
||||
this.omap.set(item, key);
|
||||
} else {
|
||||
this.pmap[item] = key;
|
||||
}
|
||||
this.store[key] = item;
|
||||
},
|
||||
|
||||
getItem: function(key) {
|
||||
key = this._parseKey(key);
|
||||
return this.store[key];
|
||||
if (key = this._parseKey(key)) {
|
||||
return this.store[key];
|
||||
}
|
||||
},
|
||||
|
||||
getItems: function() {
|
||||
|
@ -85,7 +85,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
var info = {};
|
||||
this._get(path, this, info);
|
||||
// Notify change to key-based path
|
||||
this._notifyPath(info.path, value, fromAbove);
|
||||
if (info.path) {
|
||||
this._notifyPath(info.path, value, fromAbove);
|
||||
}
|
||||
},
|
||||
|
||||
// Note: this implemetation only accepts key-based array paths
|
||||
|
Loading…
Reference in New Issue
Block a user