cross-domain-safe-weakmap
Advanced tools
Comparing version 1.0.23 to 1.0.24
@@ -278,3 +278,3 @@ !function(root, factory) { | ||
} | ||
if (this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) try { | ||
var name = this.name, entry = key[name]; | ||
@@ -285,10 +285,10 @@ entry && entry[0] === key ? entry[1] = value : defineProperty(key, name, { | ||
}); | ||
} else { | ||
this._cleanupClosedWindows(); | ||
var keys = this.keys, values = this.values, index = safeIndexOf(keys, key); | ||
if (-1 === index) { | ||
keys.push(key); | ||
values.push(value); | ||
} else values[index] = value; | ||
} | ||
return; | ||
} catch (err) {} | ||
this._cleanupClosedWindows(); | ||
var keys = this.keys, values = this.values, index = safeIndexOf(keys, key); | ||
if (-1 === index) { | ||
keys.push(key); | ||
values.push(value); | ||
} else values[index] = value; | ||
}; | ||
@@ -299,14 +299,13 @@ CrossDomainSafeWeakMap.prototype.get = function(key) { | ||
if (weakmap) try { | ||
if (weakmap.has(key)) return weakmap.get(key); | ||
return weakmap.has(key) ? weakmap.get(key) : void 0; | ||
} catch (err) { | ||
delete this.weakmap; | ||
} | ||
if (!this.isSafeToReadWrite(key)) { | ||
this._cleanupClosedWindows(); | ||
var index = safeIndexOf(this.keys, key); | ||
if (-1 === index) return; | ||
return this.values[index]; | ||
} | ||
var entry = key[this.name]; | ||
if (entry && entry[0] === key) return entry[1]; | ||
if (this.isSafeToReadWrite(key)) try { | ||
var entry = key[this.name]; | ||
return entry && entry[0] === key ? entry[1] : void 0; | ||
} catch (err) {} | ||
this._cleanupClosedWindows(); | ||
var index = safeIndexOf(this.keys, key); | ||
if (-1 !== index) return this.values[index]; | ||
}; | ||
@@ -321,12 +320,11 @@ CrossDomainSafeWeakMap.prototype.delete = function(key) { | ||
} | ||
if (this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) try { | ||
var entry = key[this.name]; | ||
entry && entry[0] === key && (entry[0] = entry[1] = void 0); | ||
} else { | ||
this._cleanupClosedWindows(); | ||
var keys = this.keys, index = safeIndexOf(keys, key); | ||
if (-1 !== index) { | ||
keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
} | ||
} catch (err) {} | ||
this._cleanupClosedWindows(); | ||
var keys = this.keys, index = safeIndexOf(keys, key); | ||
if (-1 !== index) { | ||
keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
} | ||
@@ -342,6 +340,6 @@ }; | ||
} | ||
if (this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) try { | ||
var entry = key[this.name]; | ||
return !(!entry || entry[0] !== key); | ||
} | ||
} catch (err) {} | ||
this._cleanupClosedWindows(); | ||
@@ -348,0 +346,0 @@ return -1 !== safeIndexOf(this.keys, key); |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("xdsweakmap",[],e):"object"==typeof exports?exports.xdsweakmap=e():t.xdsweakmap=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){"use strict";r.d(e,"a",function(){return n}),r.d(e,"b",function(){return i});var n={MOCK:"mock:",FILE:"file:",ABOUT:"about:"},i="*"},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={};r.d(n,"WeakMap",function(){return u});var i=r(2);function a(t,e){for(var r=0;r<t.length;r++)try{if(t[r]===e)return r}catch(t){}return-1}var o=Object.defineProperty,c=Date.now()%1e9,u=function(){function t(){if(function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),c+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+c,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var t=new WeakMap,e={};return Object.freeze(e),t.set(e,"__testvalue__"),"__testvalue__"===t.get(e)}catch(t){return!1}}())try{this.weakmap=new WeakMap}catch(t){}this.keys=[],this.values=[]}return t.prototype._cleanupClosedWindows=function(){for(var t=this.weakmap,e=this.keys,r=0;r<e.length;r++){var n=e[r];if(Object(i.isWindow)(n)&&Object(i.isWindowClosed)(n)){if(t)try{t.delete(n)}catch(t){}e.splice(r,1),this.values.splice(r,1),r-=1}}},t.prototype.isSafeToReadWrite=function(t){if(Object(i.isWindow)(t))return!1;try{t&&t.self,t&&t[this.name]}catch(t){return!1}return!0},t.prototype.set=function(t,e){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(t,e)}catch(t){delete this.weakmap}if(this.isSafeToReadWrite(t)){var n=this.name,i=t[n];i&&i[0]===t?i[1]=e:o(t,n,{value:[t,e],writable:!0})}else{this._cleanupClosedWindows();var c=this.keys,u=this.values,s=a(c,t);-1===s?(c.push(t),u.push(e)):u[s]=e}},t.prototype.get=function(t){if(!t)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(t))return e.get(t)}catch(t){delete this.weakmap}if(!this.isSafeToReadWrite(t)){this._cleanupClosedWindows();var r=a(this.keys,t);if(-1===r)return;return this.values[r]}var n=t[this.name];if(n&&n[0]===t)return n[1]},t.prototype.delete=function(t){if(!t)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{e.delete(t)}catch(t){delete this.weakmap}if(this.isSafeToReadWrite(t)){var r=t[this.name];r&&r[0]===t&&(r[0]=r[1]=void 0)}else{this._cleanupClosedWindows();var n=this.keys,i=a(n,t);-1!==i&&(n.splice(i,1),this.values.splice(i,1))}},t.prototype.has=function(t){if(!t)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(t))return!0}catch(t){delete this.weakmap}if(this.isSafeToReadWrite(t)){var r=t[this.name];return!(!r||r[0]!==t)}return this._cleanupClosedWindows(),-1!==a(this.keys,t)},t.prototype.getOrSet=function(t,e){if(this.has(t))return this.get(t);var r=e();return this.set(t,r),r},t}();r.d(e,"WeakMap",function(){return u}),e.default=n},function(t,e,r){"use strict";var n=r(3);r.d(e,"isWindow",function(){return n.a}),r.d(e,"isWindowClosed",function(){return n.b});var i=r(4);r.n(i),r(0)},function(t,e,r){"use strict";var n=r(0);e.b=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{if(t===window)return!1}catch(t){return!0}try{if(!t)return!0}catch(t){return!0}try{if(t.closed)return!0}catch(t){return!t||t.message!==i}if(e&&function(t){if(!function(t){try{if(t===window)return!0}catch(t){}try{var e=Object.getOwnPropertyDescriptor(t,"location");if(e&&!1===e.enumerable)return!1}catch(t){}try{if(a(t)&&o(t))return!0}catch(t){}try{if(c(t)===c(window))return!0}catch(t){}return!1}(t))return!1;try{if(t===window)return!0;if(a(t)&&o(t))return!0;if(u(window)===u(t))return!0}catch(t){}return!1}(t))try{if(t.mockclosed)return!0}catch(t){}try{if(!t.parent||!t.top)return!0}catch(t){}var r=function(t,e){for(var r=0;r<t.length;r++)try{if(t[r]===e)return r}catch(t){}return-1}(s,t);if(-1!==r){var n=f[r];if(n&&function(t){if(!t.contentWindow)return!0;if(!t.parentNode)return!0;var e=t.ownerDocument;return!(!e||!e.documentElement||e.documentElement.contains(t))}(n))return!0}return!1},e.a=function(t){try{if(t===window)return!0}catch(t){if(t&&t.message===i)return!0}try{if("[object Window]"===Object.prototype.toString.call(t))return!0}catch(t){if(t&&t.message===i)return!0}try{if(window.Window&&t instanceof window.Window)return!0}catch(t){if(t&&t.message===i)return!0}try{if(t&&t.self===t)return!0}catch(t){if(t&&t.message===i)return!0}try{if(t&&t.parent===t)return!0}catch(t){if(t&&t.message===i)return!0}try{if(t&&t.top===t)return!0}catch(t){if(t&&t.message===i)return!0}try{t&&t.__cross_domain_utils_window_check__}catch(t){return!0}return!1};var i="Call was rejected by callee.\r\n";function a(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).location.protocol===n.a.ABOUT}function o(t){try{return t&&t.location&&t.location.href,!0}catch(t){}return!1}function c(t){var e=(t=t||window).location;if(!e)throw new Error("Can not read window location");var r=e.protocol;if(!r)throw new Error("Can not read window protocol");if(r===n.a.FILE)return n.a.FILE+"//";if(r===n.a.ABOUT){var i=function(t){if(t)try{if(t.parent&&t.parent!==t)return t.parent}catch(t){}}(t);return i&&o(i)?c(i):n.a.ABOUT+"//"}var a=e.host;if(!a)throw new Error("Can not read window host");return r+"//"+a}function u(t){var e=c(t=t||window);return e&&t.mockDomain&&0===t.mockDomain.indexOf(n.a.MOCK)?t.mockDomain:e}var s=[],f=[]},function(t,e){}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("xdsweakmap",[],e):"object"==typeof exports?exports.xdsweakmap=e():t.xdsweakmap=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){"use strict";r.d(e,"a",function(){return n}),r.d(e,"b",function(){return i});var n={MOCK:"mock:",FILE:"file:",ABOUT:"about:"},i="*"},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={};r.d(n,"WeakMap",function(){return u});var i=r(2);function a(t,e){for(var r=0;r<t.length;r++)try{if(t[r]===e)return r}catch(t){}return-1}var o=Object.defineProperty,c=Date.now()%1e9,u=function(){function t(){if(function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),c+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+c,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var t=new WeakMap,e={};return Object.freeze(e),t.set(e,"__testvalue__"),"__testvalue__"===t.get(e)}catch(t){return!1}}())try{this.weakmap=new WeakMap}catch(t){}this.keys=[],this.values=[]}return t.prototype._cleanupClosedWindows=function(){for(var t=this.weakmap,e=this.keys,r=0;r<e.length;r++){var n=e[r];if(Object(i.isWindow)(n)&&Object(i.isWindowClosed)(n)){if(t)try{t.delete(n)}catch(t){}e.splice(r,1),this.values.splice(r,1),r-=1}}},t.prototype.isSafeToReadWrite=function(t){if(Object(i.isWindow)(t))return!1;try{t&&t.self,t&&t[this.name]}catch(t){return!1}return!0},t.prototype.set=function(t,e){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(t,e)}catch(t){delete this.weakmap}if(this.isSafeToReadWrite(t))try{var n=this.name,i=t[n];return void(i&&i[0]===t?i[1]=e:o(t,n,{value:[t,e],writable:!0}))}catch(t){}this._cleanupClosedWindows();var c=this.keys,u=this.values,s=a(c,t);-1===s?(c.push(t),u.push(e)):u[s]=e},t.prototype.get=function(t){if(!t)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{return e.has(t)?e.get(t):void 0}catch(t){delete this.weakmap}if(this.isSafeToReadWrite(t))try{var r=t[this.name];return r&&r[0]===t?r[1]:void 0}catch(t){}this._cleanupClosedWindows();var n=a(this.keys,t);if(-1!==n)return this.values[n]},t.prototype.delete=function(t){if(!t)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{e.delete(t)}catch(t){delete this.weakmap}if(this.isSafeToReadWrite(t))try{var r=t[this.name];r&&r[0]===t&&(r[0]=r[1]=void 0)}catch(t){}this._cleanupClosedWindows();var n=this.keys,i=a(n,t);-1!==i&&(n.splice(i,1),this.values.splice(i,1))},t.prototype.has=function(t){if(!t)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(t))return!0}catch(t){delete this.weakmap}if(this.isSafeToReadWrite(t))try{var r=t[this.name];return!(!r||r[0]!==t)}catch(t){}return this._cleanupClosedWindows(),-1!==a(this.keys,t)},t.prototype.getOrSet=function(t,e){if(this.has(t))return this.get(t);var r=e();return this.set(t,r),r},t}();r.d(e,"WeakMap",function(){return u}),e.default=n},function(t,e,r){"use strict";var n=r(3);r.d(e,"isWindow",function(){return n.a}),r.d(e,"isWindowClosed",function(){return n.b});var i=r(4);r.n(i),r(0)},function(t,e,r){"use strict";var n=r(0);e.b=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{if(t===window)return!1}catch(t){return!0}try{if(!t)return!0}catch(t){return!0}try{if(t.closed)return!0}catch(t){return!t||t.message!==i}if(e&&function(t){if(!function(t){try{if(t===window)return!0}catch(t){}try{var e=Object.getOwnPropertyDescriptor(t,"location");if(e&&!1===e.enumerable)return!1}catch(t){}try{if(a(t)&&o(t))return!0}catch(t){}try{if(c(t)===c(window))return!0}catch(t){}return!1}(t))return!1;try{if(t===window)return!0;if(a(t)&&o(t))return!0;if(u(window)===u(t))return!0}catch(t){}return!1}(t))try{if(t.mockclosed)return!0}catch(t){}try{if(!t.parent||!t.top)return!0}catch(t){}var r=function(t,e){for(var r=0;r<t.length;r++)try{if(t[r]===e)return r}catch(t){}return-1}(s,t);if(-1!==r){var n=f[r];if(n&&function(t){if(!t.contentWindow)return!0;if(!t.parentNode)return!0;var e=t.ownerDocument;return!(!e||!e.documentElement||e.documentElement.contains(t))}(n))return!0}return!1},e.a=function(t){try{if(t===window)return!0}catch(t){if(t&&t.message===i)return!0}try{if("[object Window]"===Object.prototype.toString.call(t))return!0}catch(t){if(t&&t.message===i)return!0}try{if(window.Window&&t instanceof window.Window)return!0}catch(t){if(t&&t.message===i)return!0}try{if(t&&t.self===t)return!0}catch(t){if(t&&t.message===i)return!0}try{if(t&&t.parent===t)return!0}catch(t){if(t&&t.message===i)return!0}try{if(t&&t.top===t)return!0}catch(t){if(t&&t.message===i)return!0}try{t&&t.__cross_domain_utils_window_check__}catch(t){return!0}return!1};var i="Call was rejected by callee.\r\n";function a(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).location.protocol===n.a.ABOUT}function o(t){try{return t&&t.location&&t.location.href,!0}catch(t){}return!1}function c(t){var e=(t=t||window).location;if(!e)throw new Error("Can not read window location");var r=e.protocol;if(!r)throw new Error("Can not read window protocol");if(r===n.a.FILE)return n.a.FILE+"//";if(r===n.a.ABOUT){var i=function(t){if(t)try{if(t.parent&&t.parent!==t)return t.parent}catch(t){}}(t);return i&&o(i)?c(i):n.a.ABOUT+"//"}var a=e.host;if(!a)throw new Error("Can not read window host");return r+"//"+a}function u(t){var e=c(t=t||window);return e&&t.mockDomain&&0===t.mockDomain.indexOf(n.a.MOCK)?t.mockDomain:e}var s=[],f=[]},function(t,e){}])}); | ||
//# sourceMappingURL=cross-domain-safe-weakmap.min.js.map |
@@ -90,29 +90,33 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
if (!this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) { | ||
try { | ||
var name = this.name; | ||
var entry = key[name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
entry[1] = value; | ||
} else { | ||
defineProperty(key, name, { | ||
value: [key, value], | ||
writable: true | ||
}); | ||
} | ||
var keys = this.keys; | ||
var values = this.values; | ||
var index = safeIndexOf(keys, key); | ||
if (index === -1) { | ||
keys.push(key); | ||
values.push(value); | ||
} else { | ||
values[index] = value; | ||
return; | ||
} catch (err) { | ||
// pass | ||
} | ||
} else { | ||
} | ||
var name = this.name; | ||
var entry = key[name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
entry[1] = value; | ||
} else { | ||
defineProperty(key, name, { | ||
value: [key, value], | ||
writable: true | ||
}); | ||
} | ||
var keys = this.keys; | ||
var values = this.values; | ||
var index = safeIndexOf(keys, key); | ||
if (index === -1) { | ||
keys.push(key); | ||
values.push(value); | ||
} else { | ||
values[index] = value; | ||
} | ||
@@ -134,2 +138,3 @@ }; | ||
} | ||
return; | ||
} catch (err) { | ||
@@ -140,22 +145,26 @@ delete this.weakmap; | ||
if (!this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) { | ||
try { | ||
var entry = key[this.name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
return entry[1]; | ||
} | ||
var keys = this.keys; | ||
var index = safeIndexOf(keys, key); | ||
if (index === -1) { | ||
return; | ||
} catch (err) { | ||
// pass | ||
} | ||
} | ||
return this.values[index]; | ||
} else { | ||
this._cleanupClosedWindows(); | ||
var entry = key[this.name]; | ||
var keys = this.keys; | ||
var index = safeIndexOf(keys, key); | ||
if (entry && entry[0] === key) { | ||
return entry[1]; | ||
} | ||
if (index === -1) { | ||
return; | ||
} | ||
return this.values[index]; | ||
}; | ||
@@ -179,20 +188,22 @@ | ||
if (!this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) { | ||
try { | ||
var entry = key[this.name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
entry[0] = entry[1] = undefined; | ||
} | ||
} catch (err) { | ||
// pass | ||
} | ||
} | ||
var keys = this.keys; | ||
var index = safeIndexOf(keys, key); | ||
this._cleanupClosedWindows(); | ||
if (index !== -1) { | ||
keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
} | ||
} else { | ||
var keys = this.keys; | ||
var index = safeIndexOf(keys, key); | ||
var entry = key[this.name]; | ||
if (entry && entry[0] === key) { | ||
entry[0] = entry[1] = undefined; | ||
} | ||
if (index !== -1) { | ||
keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
} | ||
@@ -219,18 +230,20 @@ }; | ||
if (!this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) { | ||
try { | ||
var entry = key[this.name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
return true; | ||
} | ||
var index = safeIndexOf(this.keys, key); | ||
return index !== -1; | ||
} else { | ||
return false; | ||
} catch (err) { | ||
// pass | ||
} | ||
} | ||
var entry = key[this.name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
var index = safeIndexOf(this.keys, key); | ||
return index !== -1; | ||
}; | ||
@@ -237,0 +250,0 @@ |
{ | ||
"name": "cross-domain-safe-weakmap", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"description": "Cross domain safe WeakMap.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -94,30 +94,34 @@ /* @flow */ | ||
if (!this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) { | ||
try { | ||
let name = this.name; | ||
let entry = key[name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
entry[1] = value; | ||
} else { | ||
defineProperty(key, name, { | ||
value: [ key, value ], | ||
writable: true | ||
}); | ||
} | ||
let keys = this.keys; | ||
let values = this.values; | ||
let index = safeIndexOf(keys, key); | ||
return; | ||
if (index === -1) { | ||
keys.push(key); | ||
values.push(value); | ||
} else { | ||
values[index] = value; | ||
} catch (err) { | ||
// pass | ||
} | ||
} | ||
} else { | ||
this._cleanupClosedWindows(); | ||
let name = this.name; | ||
let entry = key[name]; | ||
let keys = this.keys; | ||
let values = this.values; | ||
let index = safeIndexOf(keys, key); | ||
if (entry && entry[0] === key) { | ||
entry[1] = value; | ||
} else { | ||
defineProperty(key, name, { | ||
value: [ key, value ], | ||
writable: true | ||
}); | ||
} | ||
if (index === -1) { | ||
keys.push(key); | ||
values.push(value); | ||
} else { | ||
values[index] = value; | ||
} | ||
@@ -139,2 +143,4 @@ } | ||
} | ||
return; | ||
} catch (err) { | ||
@@ -145,23 +151,26 @@ delete this.weakmap; | ||
if (!this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) { | ||
try { | ||
let entry = key[this.name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
return entry[1]; | ||
} | ||
let keys = this.keys; | ||
let index = safeIndexOf(keys, key); | ||
if (index === -1) { | ||
return; | ||
} catch (err) { | ||
// pass | ||
} | ||
} | ||
return this.values[index]; | ||
this._cleanupClosedWindows(); | ||
} else { | ||
let keys = this.keys; | ||
let index = safeIndexOf(keys, key); | ||
let entry = key[this.name]; | ||
if (index === -1) { | ||
return; | ||
} | ||
if (entry && entry[0] === key) { | ||
return entry[1]; | ||
} | ||
} | ||
return this.values[index]; | ||
} | ||
@@ -185,21 +194,22 @@ | ||
if (!this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) { | ||
try { | ||
let entry = key[this.name]; | ||
this._cleanupClosedWindows(); | ||
let keys = this.keys; | ||
let index = safeIndexOf(keys, key); | ||
if (index !== -1) { | ||
keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
if (entry && entry[0] === key) { | ||
entry[0] = entry[1] = undefined; | ||
} | ||
} catch (err) { | ||
// pass | ||
} | ||
} | ||
} else { | ||
this._cleanupClosedWindows(); | ||
let entry = key[this.name]; | ||
let keys = this.keys; | ||
let index = safeIndexOf(keys, key); | ||
if (entry && entry[0] === key) { | ||
entry[0] = entry[1] = undefined; | ||
} | ||
if (index !== -1) { | ||
keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
} | ||
@@ -226,19 +236,20 @@ } | ||
if (!this.isSafeToReadWrite(key)) { | ||
if (this.isSafeToReadWrite(key)) { | ||
try { | ||
let entry = key[this.name]; | ||
this._cleanupClosedWindows(); | ||
if (entry && entry[0] === key) { | ||
return true; | ||
} | ||
let index = safeIndexOf(this.keys, key); | ||
return index !== -1; | ||
return false; | ||
} catch (err) { | ||
// pass | ||
} | ||
} | ||
} else { | ||
this._cleanupClosedWindows(); | ||
let entry = key[this.name]; | ||
if (entry && entry[0] === key) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
let index = safeIndexOf(this.keys, key); | ||
return index !== -1; | ||
} | ||
@@ -245,0 +256,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
134712
863