Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28916

Re: Change all background-color attribute values

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Change all background-color attribute values
Date 2015-11-23 11:27 +0000
Organization PointedEars Software (PES)
Message-ID <2485000.dqr6z4OEcz@PointedEars.de> (permalink)
References <n2sj7k$ttl$1@speranza.aioe.org> <2033421.7ht7S6j6Qy@PointedEars.de>

Show all headers | View raw


Thomas 'PointedEars' Lahn wrote:

>   [].slice.call(document.styleSheets).forEach(function (styleSheet) {
>     [].slice.call(styleSheet.cssRules || styleSheet.rules, function (rule)
>     [{
>       var bgColor = rule.style["background-color"];
>       if (bgColor) rule.style["background-color"] = some_funct(bgColor);
>     });
>   });

Correction:

  var _slice = [].slice;
  _slice.call(document.styleSheets).forEach(function (styleSheet) {
    _slice.call(styleSheet.cssRules || styleSheet.rules).forEach(
      function changeRule (rule) {
        /* @media, @keyframes etc. rules */
        if (rule.cssText.substring(0, 1) == "@")
        {
          return _slice.call(rule.cssRules).forEach(changeRule);
        }

        var bgColor = rule.style.backgroundColor;
        if (bgColor) rule.style.backgroundColor = some_funct(bgColor);
      });
  });

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 15:24 +0100
  Re: Change all background-color attribute values Martin Honnen <mahotrash@yahoo.de> - 2015-11-22 16:19 +0100
    Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 16:38 +0100
      Re: Change all background-color attribute values Martin Honnen <mahotrash@yahoo.de> - 2015-11-22 17:02 +0100
        Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 18:18 +0100
          Re: Change all background-color attribute values Martin Honnen <mahotrash@yahoo.de> - 2015-11-22 19:27 +0100
          Re: Change all background-color attribute values Scott Sauyet <scott.sauyet@gmail.com> - 2015-11-22 11:33 -0800
            Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-23 16:01 +0100
  Re: Change all background-color attribute values JJ <jj4public@vfemail.net> - 2015-11-22 22:32 +0700
    Re: Change all background-color attribute values JJ <jj4public@vfemail.net> - 2015-11-22 22:47 +0700
      Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 16:54 +0100
    Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 16:49 +0100
  Re: Change all background-color attribute values Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-11-23 01:11 +0000
    Re: Change all background-color attribute values Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-11-23 11:27 +0000

csiph-web