Code coverage report for juice\lib\property.js

Statements: 100% (18 / 18)      Branches: 100% (6 / 6)      Functions: 100% (3 / 3)      Lines: 100% (18 / 18)      Ignored: none     

All files » juice\lib\ » property.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 50 51 52 53 54 55    1           1                     1 439 439 439 439                 1 56 56 56 56 56   56 12   44                 1 1    
'use strict';
 
module.exports = exports = Property;
 
/**
 * Module dependencies.
 */
 
var utils = require('./utils');
 
/**
 * CSS property constructor.
 *
 * @param {String} property
 * @param {String} value
 * @param {Selector} selector the property originates from
 * @api public
 */
 
function Property(prop, value, selector, priority) {
  this.prop = prop;
  this.value = value;
  this.selector = selector;
  this.priority = priority || 0;
}
 
/**
 * Compares with another Property based on Selector#specificity.
 *
 * @api public
 */
 
Property.prototype.compare = function(property) {
  var a = this.selector.specificity();
  a[0] += this.priority;
  var b = property.selector.specificity();
  b[0] += property.priority;
  var winner = utils.compare(a, b);
 
  if (winner === a && a !== b) {
    return this;
  }
  return property;
};
 
/**
 * Returns CSS property
 *
 * @api public
 */
 
Property.prototype.toString = function() {
  return this.prop + ': ' + this.value.replace(/['"]+/g, '') + ';';
};