mirror of https://github.com/gorhill/uBlock.git
Prevent picker's preview mode from modifying style attribute
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/551 The issue fixes previewing the hiding/unhiding of targeted elements in the element picker. However it does not address the case of previewing `:style(...)` operators -- this would require a much more complex fix, which I am not sure is worth the amount of work and increased code complexity.
This commit is contained in:
parent
9cbdff1a9d
commit
62387fb87a
|
@ -883,16 +883,15 @@ const filterToDOMInterface = (function() {
|
||||||
const elem = item.elem;
|
const elem = item.elem;
|
||||||
// https://github.com/gorhill/uBlock/issues/1629
|
// https://github.com/gorhill/uBlock/issues/1629
|
||||||
if ( elem === pickerRoot ) { continue; }
|
if ( elem === pickerRoot ) { continue; }
|
||||||
const style = elem.style;
|
|
||||||
if (
|
if (
|
||||||
(elem !== htmlElem) &&
|
(elem !== htmlElem) &&
|
||||||
(item.type === 'cosmetic' || item.type === 'network' && item.src !== undefined)
|
(item.type === 'cosmetic' || item.type === 'network' && item.src !== undefined)
|
||||||
) {
|
) {
|
||||||
item.display = style.getPropertyValue('display');
|
vAPI.domFilterer.hideNode(elem);
|
||||||
item.displayPriority = style.getPropertyPriority('display');
|
item.hidden = true;
|
||||||
style.setProperty('display', 'none', 'important');
|
|
||||||
}
|
}
|
||||||
if ( item.type === 'network' && item.style === 'background-image' ) {
|
if ( item.type === 'network' && item.style === 'background-image' ) {
|
||||||
|
const style = elem.style;
|
||||||
item.backgroundImage = style.getPropertyValue('background-image');
|
item.backgroundImage = style.getPropertyValue('background-image');
|
||||||
item.backgroundImagePriority = style.getPropertyPriority('background-image');
|
item.backgroundImagePriority = style.getPropertyPriority('background-image');
|
||||||
style.setProperty('background-image', 'none', 'important');
|
style.setProperty('background-image', 'none', 'important');
|
||||||
|
@ -903,13 +902,9 @@ const filterToDOMInterface = (function() {
|
||||||
const unapplyHide = function() {
|
const unapplyHide = function() {
|
||||||
if ( lastResultset === undefined ) { return; }
|
if ( lastResultset === undefined ) { return; }
|
||||||
for ( const item of lastResultset ) {
|
for ( const item of lastResultset ) {
|
||||||
if ( item.hasOwnProperty('display') ) {
|
if ( item.hidden === true ) {
|
||||||
item.elem.style.setProperty(
|
vAPI.domFilterer.unhideNode(item.elem);
|
||||||
'display',
|
item.hidden = false;
|
||||||
item.display,
|
|
||||||
item.displayPriority
|
|
||||||
);
|
|
||||||
delete item.display;
|
|
||||||
}
|
}
|
||||||
if ( item.hasOwnProperty('backgroundImage') ) {
|
if ( item.hasOwnProperty('backgroundImage') ) {
|
||||||
item.elem.style.setProperty(
|
item.elem.style.setProperty(
|
||||||
|
|
Loading…
Reference in New Issue