# Code coverage report for lib/attributes/style.js

## Statements: 87.5% (14 / 16) Branches: 75% (6 / 8) Functions: 100% (3 / 3) Lines: 87.5% (14 / 16) Ignored: none

All files » lib/attributes/ » style.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    501

    1

    2
    2

    53

    53

    53
    106
    106
    5

    53
    53

    1
    4

     var ScriptAttribute = require("./script");

    /**
     */

    module.exports = ScriptAttribute.extend({

      /**
       */

      bind: function() {
        this._currentStyles = {};
        ScriptAttribute.prototype.bind.call(this);
      },

      /**
       */

      update: function() {

        var styles = this.currentValue;

        var newStyles = {};

        for (var name in styles) {
          var style = styles[name];
          if (style !== this._currentStyles[name]) {
            newStyles[name] = this._currentStyles[name] = style || "";
          }
        }

        Eif (this.node.__isNode) {
          this.node.style.setProperties(newStyles);
        } else {
          for (var key in newStyles) {
            this.node.style[key] = newStyles[key];
          }
        }
      }
    });

    /**
     */

    module.exports.test = function(value) {
      return typeof value === "object" && !value.buffered;
    };