From da992312f378fc3396034fcfb39fcdb308804956 Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 20 Mar 2017 17:01:19 -0400 Subject: [PATCH] fix #711 (will need confirmations) --- src/js/popup.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/js/popup.js b/src/js/popup.js index 2e72277..0e04cd6 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -67,9 +67,10 @@ var matrixHeaderPrettyNames = { var firstPartyLabel = ''; var blacklistedHostnamesLabel = ''; +var expandosIdGenerator = 1; var nodeToExpandosMap = (function() { - if ( typeof window.WeakMap === 'function' ) { - return new window.WeakMap(); + if ( typeof window.Map === 'function' ) { + return new window.Map(); } })(); @@ -81,9 +82,14 @@ var expandosFromNode = function(node) { node = node.nodeAt(0); } if ( nodeToExpandosMap ) { - var expandos = nodeToExpandosMap.get(node); + var expandosId = node.getAttribute('data-expandos'); + if ( !expandosId ) { + expandosId = '' + (expandosIdGenerator++); + node.setAttribute('data-expandos', expandosId); + } + var expandos = nodeToExpandosMap.get(expandosId); if ( expandos === undefined ) { - nodeToExpandosMap.set(node, (expandos = Object.create(null))); + nodeToExpandosMap.set(expandosId, (expandos = Object.create(null))); } return expandos; }