Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include.postload.js

Issue 5744307206094848: Issue 1658 - Preserve original "style" atribute for generated filters (Closed)
Patch Set: Created Dec. 4, 2014, 5:25 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -76,6 +76,14 @@
return shadow.getDistributedNodes()[0] == child;
}
+function getOriginalStyle(element)
+{
+ if ("_originalStyle" in element)
+ return element._originalStyle;
+
+ return element.getAttribute("style");
+}
+
function highlightElement(element, shadowColor, backgroundColor)
{
unhighlightElement(element);
@@ -108,6 +116,8 @@
var originalBoxShadow = element.style.getPropertyValue("box-shadow");
var originalBackgroundColor = element.style.getPropertyValue("background-color");
+ element._originalStyle = getOriginalStyle(element);
+
element.style.setProperty("box-shadow", boxShadow, "important");
element.style.setProperty("background-color", backgroundColor, "important");
@@ -342,7 +352,7 @@
return;
var target = e.target;
- while (target.parentNode && !(target.id || target.className || target.src || /:.+:/.test(target.getAttribute("style"))))
+ while (target.parentNode && !(target.id || target.className || target.src || /:.+:/.test(getOriginalStyle(target))))
target = target.parentNode;
if (target == document.documentElement || target == document.body)
target = null;
@@ -442,14 +452,10 @@
addSelector(selector);
}
- // restore the original style, before generating the fallback filter that
- // will include the style, and to prevent highlightElements from saving those
- unhighlightElement(currentElement);
-
// as last resort, create a filter based on inline styles
if (clickHideFilters.length == 0)
{
- var style = elt.getAttribute("style");
+ var style = getOriginalStyle(elt);
if (style)
addSelector(escapeCSS(elt.localName) + '[style=' + quote(style) + ']');
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld