33// @namespace http://axSgrease.nvaccess.org/
44// @description Improves the accessibility of some site.
55// @author James Teh <jteh@mozilla.com>
6- // @copyright 2019 Mozilla Corporation, Derek Riemer
6+ // @copyright 2019-2022 Mozilla Corporation, Derek Riemer
77// @license Mozilla Public License version 2.0
88// @version 2019.1
99// @include https://some.site/*
@@ -83,13 +83,15 @@ function applyTweak(el, tweak) {
8383 }
8484}
8585
86- function applyTweaks ( root , tweaks , checkRoot ) {
86+ function applyTweaks ( root , tweaks , checkRoot , forAttrChange = false ) {
8787 for ( let tweak of tweaks ) {
88- for ( let el of root . querySelectorAll ( tweak . selector ) ) {
89- try {
90- applyTweak ( el , tweak ) ;
91- } catch ( e ) {
92- console . log ( "Exception while applying tweak for '" + tweak . selector + "': " + e ) ;
88+ if ( ! forAttrChange || tweak . whenAttrChangedOnAncestor !== false ) {
89+ for ( let el of root . querySelectorAll ( tweak . selector ) ) {
90+ try {
91+ applyTweak ( el , tweak ) ;
92+ } catch ( e ) {
93+ console . log ( "Exception while applying tweak for '" + tweak . selector + "': " + e ) ;
94+ }
9395 }
9496 }
9597 if ( checkRoot && root . matches ( tweak . selector ) ) {
@@ -113,7 +115,7 @@ let observer = new MutationObserver(function(mutations) {
113115 applyTweaks ( node , DYNAMIC_TWEAKS , true ) ;
114116 }
115117 } else if ( mutation . type === "attributes" ) {
116- applyTweaks ( mutation . target , DYNAMIC_TWEAKS , true ) ;
118+ applyTweaks ( mutation . target , DYNAMIC_TWEAKS , true , true ) ;
117119 }
118120 } catch ( e ) {
119121 // Catch exceptions for individual mutations so other mutations are still handled.
0 commit comments