From 62a4cafe2f59264dc4a1782a63371b5bc6ddf2e4 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 19 Apr 2016 09:15:06 -0400 Subject: [PATCH] code review re. #1202: mind style priority (repro case at #1575) --- src/epicker.html | 5 +---- src/js/scriptlets/element-picker.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/epicker.html b/src/epicker.html index dc5d0d1b9..6f4cdc48a 100644 --- a/src/epicker.html +++ b/src/epicker.html @@ -134,10 +134,7 @@ svg > path + path { stroke-width: 0.5px; fill: rgba(255,63,63,0.20); } -body.preview svg > path:first-child { - fill: rgba(0,0,0,0.10); -} -body.preview svg > path + path { +body.preview svg > path { fill: rgba(0,0,0,0.10); } aside { diff --git a/src/js/scriptlets/element-picker.js b/src/js/scriptlets/element-picker.js index a8e59387c..f31f12c7c 100644 --- a/src/js/scriptlets/element-picker.js +++ b/src/js/scriptlets/element-picker.js @@ -284,17 +284,19 @@ var filterElements = function(filter) { previewedElements.push({ elem: elem, prop: 'display', - value: style.display + value: style.getPropertyValue('display'), + priority: style.getPropertyPriority('display') }); - style.display = 'none'; + style.setProperty('display', 'none', 'important'); } if ( item.type === 'network' && item.style === 'background-image' ) { previewedElements.push({ elem: elem, prop: 'background-image', - value: style.backgroundImage - }); - style.backgroundImage = 'none'; + value: style.getPropertyValue('background-image'), + priority: style.getPropertyPriority('background-image') + }); + style.setProperty('background-image', 'none', 'important'); } } }; @@ -313,7 +315,7 @@ var unpreview = function() { var i = items.length, item; while ( i-- ) { item = items[i]; - item.elem.style[item.prop] = item.value; + item.elem.style.setProperty(item.prop, item.value, item.priority); } previewedElements.length = 0; pickerBody.classList.remove('preview');