www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 1247896d70c5c8aa3e8ff13cd4d28e8910368f81
parent 4ffbf6fca55f83a190345d8c730e777276f380f4
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 13 Jul 2017 01:16:29 -0400

Fix crash from tag name collision with Object properties in tag selector

Diffstat:
Mchrome/content/zotero/bindings/tagselector.xml | 26++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml @@ -121,23 +121,25 @@ <field name="_hasScope">false</field> <field name="_scope">null</field> - <property name="scope" onget="return this._scope"> + <property name="scope"> <setter> <![CDATA[ if (val.length) { this._hasScope = true; - this._scope = {}; + this._scope = new Map(); for (let i=0; i<val.length; i++) { let tag = val[i]; - if (!this._scope[tag.tag]) { - this._scope[tag.tag] = []; + let types = this._scope.get(tag.tag); + if (!types) { + types = [] } - this._scope[tag.tag].push(tag.type || 0); + types.push(tag.type || 0); + this._scope.set(tag.tag, types); } } else { this._hasScope = false; - this._scope = {}; + this._scope = new Map(); } this.refresh(); @@ -268,21 +270,21 @@ // Otherwise just update based on visibility else { // If only a few tags, regenerate buttons from scratch - if (this.filterToScope && Object.keys(this.scope).length <= 100) { + if (this.filterToScope && this._scope.size <= 100) { // If full set is currently displayed, store it for later if (!this._tagsDiv) { this._tagsDiv = tagsBox.firstChild; } let tags = []; - for (let name in this.scope) { - tags.push(...this.scope[name].map(type => { + this._scope.forEach(function (types, name) { + tags.push(...types.map(type => { return { tag: name, - type: type + type }; })); - } + }); let { div, emptyRegular } = this.createTagsList(tags); tagsBox.replaceChild(div, tagsBox.firstChild); this._emptyRegular = emptyRegular; @@ -944,7 +946,7 @@ // Check tags against scope if (this._hasScope) { - var inScope = !!this._scope[name]; + var inScope = this._scope.has(name); } // If not in search, hide