CSSStyleDeclaration/0000755000175000017500000000000012337414256013040 5ustar wmbwmbCSSStyleDeclaration/.gitignore0000644000175000017500000000001412337414256015023 0ustar wmbwmbnode_modulesCSSStyleDeclaration/README.md0000644000175000017500000000277012337414256014325 0ustar wmbwmbCSSStyleDeclaration =================== CSSStyleDeclaration is a work-a-like to the CSSStyleDeclaration class in Nikita Vasilyev's [CSSOM](https://github.com/NV/CSSOM). I made it so that when using [jQuery in node](https://github.com/tmtk75/node-jquery) setting css attributes via $.fn.css() would work. node-jquery uses [jsdom](https://github.com/tmpvar/jsdom) to create a DOM to use in node. jsdom uses CSSOM for styling, and CSSOM's implementation of the [CSSStyleDeclaration](http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration) doesn't support [CSS2Properties](http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties), which is how jQuery's [$.fn.css()](http://api.jquery.com/css/) operates. Why not just issue a pull request? ---- Well, NV wants to keep CSSOM fast (which I can appreciate) and CSS2Properties aren't required by the standard (though every browser has the interface). So I figured the path of least resistence would be to just modify this one class, publish it as a node module (that requires CSSOM) and then make a pull request of jsdom to use it. How do I test this code? --- `npm test` should do the trick, assuming you have the dev dependencies installed: > ``` > $ npm test > > tests > ✔ Verify Has Properties > ✔ Verify Has Functions > ✔ Verify Has Special Properties > ✔ Test From Style String > ✔ Test From Properties > ✔ Test Shorthand Properties > ✔ Test width and height Properties and null and empty strings > ✔ Test Implicit Properties > ``` CSSStyleDeclaration/MIT-LICENSE.txt0000644000175000017500000000203212337414256015307 0ustar wmbwmbCopyright (c) Chad Walker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CSSStyleDeclaration/package.json0000644000175000017500000000210112337414256015320 0ustar wmbwmb{ "name": "cssstyle", "description": "CSSStyleDeclaration Object Model implementation", "keywords": ["CSS", "CSSStyleDeclaration", "StyleSheet"], "version": "0.2.14", "homepage": "https://github.com/chad3814/CSSStyleDeclaration", "maintainers": [{ "name": "Chad Walker", "email": "chad@chad-cat-lore-eddie.com", "url": "https://github.com/chad3814" }], "contributors": [ { "name": "Nikita Vasilyev", "email": "me@elv1s.ru" } ], "repository": { "type": "git", "url": "git://github.com/chad3814/CSSStyleDeclaration.git" }, "bugs": { "url": "https://github.com/chad3814/CSSStyleDeclaration/issues" }, "directories": { "lib": "./lib" }, "main": "./lib/CSSStyleDeclaration.js", "dependencies": { "cssom" : "0.3.x" }, "devDependencies" : { "nodeunit": "~0.8.0" }, "scripts": { "test": "nodeunit tests" }, "licenses": [ { "type": "MIT", "url": "http://creativecommons.org/licenses/MIT/" } ] } CSSStyleDeclaration/lib/0000755000175000017500000000000012337414256013606 5ustar wmbwmbCSSStyleDeclaration/lib/parsers.js0000644000175000017500000004457512337414256015642 0ustar wmbwmb/********************************************************************* * These are commonly used parsers for CSS Values they take a string * * to parse and return a string after it's been converted, if needed * ********************************************************************/ 'use strict'; exports.TYPES = { INTEGER: 1, NUMBER: 2, LENGTH: 3, PERCENT: 4, URL: 5, COLOR: 6, STRING: 7, ANGLE: 8, KEYWORD: 9, NULL_OR_EMPTY_STR: 10 }; /*jslint regexp: true*/ // rough regular expressions var integerRegEx = /^[\-+]?[0-9]+$/; var numberRegEx = /^[\-+]?[0-9]*\.[0-9]+$/; var lengthRegEx = /^(0|[\-+]?[0-9]?\.?[0-9]+(in|cm|em|mm|pt|pc|px))$/; var percentRegEx = /^[\-+]?[0-9]?\.?[0-9]+%$/; var urlRegEx = /^url\(\s*([^\)]*)\s*\)$/; var stringRegEx = /^("[^"]*"|'[^']*')$/; var colorRegEx1 = /^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])?$/; var colorRegEx2 = /^rgb\(([^\)]*)\)$/; var colorRegEx3 = /^rgba\(([^\)]*)\)$/; var angleRegEx = /^([\-+]?[0-9]?\.?[0-9]+)(deg|grad|rad)$/; /*jslint regexp: false*/ // This will return one of the above types based on the passed in string exports.valueType = function valueType(val) { if (val === '' || val === null) { return exports.TYPES.NULL_OR_EMPTY_STR; } if (typeof val === 'number') { val = val.toString(); } if (typeof val !== 'string') { return undefined; } if (integerRegEx.test(val)) { return exports.TYPES.INTEGER; } if (numberRegEx.test(val)) { return exports.TYPES.NUMBER; } if (lengthRegEx.test(val)) { return exports.TYPES.LENGTH; } if (percentRegEx.test(val)) { return exports.TYPES.PERCENT; } if (urlRegEx.test(val)) { return exports.TYPES.URL; } if (stringRegEx.test(val)) { return exports.TYPES.STRING; } if (angleRegEx.test(val)) { return exports.TYPES.ANGLE; } if (colorRegEx1.test(val)) { return exports.TYPES.COLOR; } var res = colorRegEx2.exec(val); var parts; if (res !== null) { parts = res[1].split(/\s*,\s*/); if (parts.length !== 3) { return undefined; } if (parts.every(percentRegEx.test.bind(percentRegEx)) || parts.every(integerRegEx.test.bind(integerRegEx))) { return exports.TYPES.COLOR; } return undefined; } res = colorRegEx3.exec(val); if (res !== null) { parts = res[1].split(/\s*,\s*/); if (parts.length !== 4) { return undefined; } if (parts.slice(0, 3).every(percentRegEx.test.bind(percentRegEx)) || parts.every(integerRegEx.test.bind(integerRegEx))) { if (numberRegEx.test(parts[3])) { return exports.TYPES.COLOR; } } return undefined; } // could still be a color, one of the standard keyword colors val = val.toLowerCase(); switch (val) { case 'maroon': case 'red': case 'orange': case 'yellow': case 'olive': case 'purple': case 'fuchsia': case 'white': case 'lime': case 'green': case 'navy': case 'blue': case 'aqua': case 'teal': case 'black': case 'silver': case 'gray': // the following are deprecated in CSS3 case 'activeborder': case 'activecaption': case 'appworkspace': case 'background': case 'buttonface': case 'buttonhighlight': case 'buttonshadow': case 'buttontext': case 'captiontext': case 'graytext': case 'highlight': case 'highlighttext': case 'inactiveborder': case 'inactivecaption': case 'inactivecaptiontext': case 'infobackground': case 'infotext': case 'menu': case 'menutext': case 'scrollbar': case 'threeddarkshadow': case 'threedface': case 'threedhighlight': case 'threedlightshadow': case 'threedshadow': case 'window': case 'windowframe': case 'windowtext': return exports.TYPES.COLOR; default: return exports.TYPES.KEYWORD; } }; exports.parseInteger = function parseInteger(val) { var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } if (type !== exports.TYPES.INTEGER) { return undefined; } return String(parseInt(val, 10)); }; exports.parseNumber = function parseNumber(val) { var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } if (type !== exports.TYPES.NUMBER) { return undefined; } return String(parseFloat(val)); }; exports.parseLength = function parseLength(val) { if (val === 0 || val === '0') { return '0px'; } var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } if (type !== exports.TYPES.LENGTH) { return undefined; } return val; }; exports.parsePercent = function parsePercent(val) { if (val === 0 || val === '0') { return '0%'; } var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } if (type !== exports.TYPES.PERCENT) { return undefined; } return val; }; // either a length or a percent exports.parseMeasurement = function parseMeasurement(val) { var length = exports.parseLength(val); if (length !== undefined) { return length; } return exports.parsePercent(val); }; exports.parseUrl = function parseUrl(val) { var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } var res = urlRegEx.exec(val); // does it match the regex? if (!res) { return undefined; } var str = res[1]; // if it starts with single or double quotes, does it end with the same? if ((str[1] === '"' || str[1] === "'") && str[1] !== str[str.length - 1]) { return undefined; } if (str[1] === '"' || str[1] === "'") { str = str.substr(1, -1); } var i; for (i = 0; i < str.length; i++) { switch (str[i]) { case '(': case ')': case ' ': case '\t': case '\n': case "'": case '"': return undefined; case '\\': i++; break; } } return 'url(' + str + ')'; }; exports.parseString = function parseString(val) { var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } if (type !== exports.TYPES.STRING) { return undefined; } var i; for (i = 1; i < val.length - 1; i++) { switch (val[i]) { case val[0]: return undefined; case '\\': i++; while (i < val.length - 1 && /[0-9A-Fa-f]/.test(val[i])) { i++; } break; } } if (i >= val.length) { return undefined; } return val; }; exports.parseColor = function parseColor(val) { var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } var red, green, blue, alpha = 1; var parts; var res = colorRegEx1.exec(val); // is it #aaa or #ababab if (res) { var hex = val.substr(1); if (hex.length === 3) { hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; } red = parseInt(hex.substr(0, 2), 16); green = parseInt(hex.substr(2, 2), 16); blue = parseInt(hex.substr(4, 2), 16); return 'rgb(' + red + ', ' + green + ', ' + blue + ')'; } res = colorRegEx2.exec(val); if (res) { parts = res[1].split(/\s*,\s*/); if (parts.length !== 3) { return undefined; } if (parts.every(percentRegEx.test.bind(percentRegEx))) { red = Math.floor(parseFloat(parts[0].slice(0, -1)) * 255 / 100); green = Math.floor(parseFloat(parts[1].slice(0, -1)) * 255 / 100); blue = Math.floor(parseFloat(parts[2].slice(0, -1)) * 255 / 100); } else if (parts.every(integerRegEx.test.bind(integerRegEx))) { red = parseInt(parts[0], 10); green = parseInt(parts[1], 10); blue = parseInt(parts[2], 10); } else { return undefined; } red = Math.min(255, Math.max(0, red)); green = Math.min(255, Math.max(0, green)); blue = Math.min(255, Math.max(0, blue)); return 'rgb(' + red + ', ' + green + ', ' + blue + ')'; } res = colorRegEx3.exec(val); if (res) { parts = res[1].split(/\s*,\s*/); if (parts.length !== 4) { return undefined; } if (parts.slice(0, 3).every(percentRegEx.test.bind(percentRegEx))) { red = Math.floor(parseFloat(parts[0].slice(0, -1)) * 255 / 100); green = Math.floor(parseFloat(parts[1].slice(0, -1)) * 255 / 100); blue = Math.floor(parseFloat(parts[2].slice(0, -1)) * 255 / 100); alpha = parseFloat(parts[3]); } else if (parts.slice(0, 3).every(integerRegEx.test.bind(integerRegEx))) { red = parseInt(parts[0], 10); green = parseInt(parts[1], 10); blue = parseInt(parts[2], 10); alpha = parseFloat(parts[3]); } else { return undefined; } if (isNaN(alpha)) { alpha = 1; } red = Math.min(255, Math.max(0, red)); green = Math.min(255, Math.max(0, green)); blue = Math.min(255, Math.max(0, blue)); alpha = Math.min(1, Math.max(0, alpha)); if (alpha === 1) { return 'rgb(' + red + ', ' + green + ', ' + blue + ')'; } return 'rgba(' + red + ', ' + green + ', ' + blue + ', ' + alpha + ')'; } if (type === exports.TYPES.COLOR) { return val; } return undefined; }; exports.parseAngle = function parseAngle(val) { var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } if (type !== exports.TYPES.ANGLE) { return undefined; } var res = angleRegEx.exec(val); var flt = parseFloat(res[1]); if (res[2] === 'rad') { flt *= 180 / Math.PI; } else if (res[2] === 'grad') { flt *= 360 / 400; } while (flt < 0) { flt += 360; } while (flt > 360) { flt -= 360; } return flt + 'deg'; }; exports.parseKeyword = function parseKeyword(val, valid_keywords) { var type = exports.valueType(val); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return val; } if (type !== exports.TYPES.KEYWORD) { return undefined; } val = val.toString().toLowerCase(); var i; for (i = 0; i < valid_keywords.length; i++) { if (valid_keywords[i].toLowerCase() === val) { return valid_keywords[i]; } } return undefined; }; // utility to translate from border-width to borderWidth var dashedToCamelCase = function (dashed) { var i; var camel = ''; var nextCap = false; for (i = 0; i < dashed.length; i++) { if (dashed[i] !== '-') { camel += nextCap ? dashed[i].toUpperCase() : dashed[i]; nextCap = false; } else { nextCap = true; } } return camel; }; var is_space = /\s/; var opening_deliminators = ['"', '\'', '(']; var closing_deliminators = ['"', '\'', ')']; // this splits on whitespace, but keeps quoted and parened parts together var getParts = function (str) { var deliminator_stack = []; var length = str.length; var i; var parts = []; var current_part = ''; var opening_index; var closing_index; for (i = 0; i < length; i++) { opening_index = opening_deliminators.indexOf(str[i]); closing_index = closing_deliminators.indexOf(str[i]); if (is_space.test(str[i])) { if (deliminator_stack.length === 0) { parts.push(current_part); current_part = ''; } else { current_part += str[i]; } } else { if (str[i] === '\\') { i++; current_part += str[i]; } else { current_part += str[i]; if (closing_index !== -1 && closing_index === deliminator_stack[deliminator_stack.length - 1]) { deliminator_stack.pop(); } else if (opening_index !== -1) { deliminator_stack.push(opening_index); } } } } if (current_part !== '') { parts.push(current_part); } return parts; }; /* * this either returns undefined meaning that it isn't valid * or returns an object where the keys are dashed short * hand properties and the values are the values to set * on them */ exports.shorthandParser = function parse(v, shorthand_for) { var type = exports.valueType(v); if (type === exports.TYPES.NULL_OR_EMPTY_STR) { return v; } if (typeof v === 'number') { v = v.toString(); } if (typeof v !== 'string') { return undefined; } if (v.toLowerCase() === 'inherit') { return {}; } var parts = getParts(v); var valid = true; var obj = {}; parts.forEach(function (part) { var part_valid = false; Object.keys(shorthand_for).forEach(function (property) { if (shorthand_for[property].isValid(part)) { part_valid = true; obj[property] = part; } }); valid = valid && part_valid; }); if (!valid) { return undefined; } return obj; }; exports.shorthandSetter = function (property, shorthand_for) { return function (v) { var obj = exports.shorthandParser(v, shorthand_for); if (obj === undefined) { return; } Object.keys(obj).forEach(function (subprop) { // in case subprop is an implicit property, this will clear // *its* subpropertiesX var camel = dashedToCamelCase(subprop); this[camel] = obj[subprop]; // in case it gets translated into something else (0 -> 0px) obj[subprop] = this[camel]; this.removeProperty(subprop); this._values[subprop] = obj[subprop]; }, this); Object.keys(shorthand_for).forEach(function (subprop) { if (!obj.hasOwnProperty(subprop)) { this.removeProperty(subprop); delete this._values[subprop]; } }, this); this.setProperty(property, v); }; }; exports.shorthandGetter = function (property, shorthand_for) { return function () { if (this._values[property] !== undefined) { return this.getPropertyValue(property); } return Object.keys(shorthand_for).map(function (subprop) { return this.getPropertyValue(subprop); }, this).filter(function (value) { return value !== ''; }).join(' '); }; }; // isValid(){1,4} | inherit // if one, it applies to all // if two, the first applies to the top and bottom, and the second to left and right // if three, the first applies to the top, the second to left and right, the third bottom // if four, top, right, bottom, left exports.implicitSetter = function (property_before, property_after, isValid, parser) { property_after = property_after || ''; if (property_after !== '') { property_after = '-' + property_after; } return function (v) { if (typeof v === 'number') { v = v.toString(); } if (typeof v !== 'string') { return undefined; } if (v.toLowerCase() === 'inherit') { return this.setProperty(property_before + property_after, v); } var parts = getParts(v); if (parts.length < 1 || parts.length > 4) { return undefined; } if (!parts.every(isValid)) { return undefined; } this.setProperty(property_before + property_after, parser(v)); this.removeProperty(property_before + '-top' + property_after); this.removeProperty(property_before + '-right' + property_after); this.removeProperty(property_before + '-bottom' + property_after); this.removeProperty(property_before + '-left' + property_after); switch (parts.length) { case 1: this._values[property_before + '-top' + property_after] = parser(parts[0]); this._values[property_before + '-right' + property_after] = parser(parts[0]); this._values[property_before + '-bottom' + property_after] = parser(parts[0]); this._values[property_before + '-left' + property_after] = parser(parts[0]); return v; case 2: this._values[property_before + '-top' + property_after] = parser(parts[0]); this._values[property_before + '-right' + property_after] = parser(parts[1]); this._values[property_before + '-bottom' + property_after] = parser(parts[0]); this._values[property_before + '-left' + property_after] = parser(parts[1]); return v; case 3: this._values[property_before + '-top' + property_after] = parser(parts[0]); this._values[property_before + '-right' + property_after] = parser(parts[1]); this._values[property_before + '-bottom' + property_after] = parser(parts[2]); this._values[property_before + '-left' + property_after] = parser(parts[1]); return v; case 4: this._values[property_before + '-top' + property_after] = parser(parts[0]); this._values[property_before + '-right' + property_after] = parser(parts[1]); this._values[property_before + '-bottom' + property_after] = parser(parts[2]); this._values[property_before + '-left' + property_after] = parser(parts[3]); return v; } }; }; var camel_to_dashed = /[A-Z]/g; /*jslint regexp: true*/ var first_segment = /^\([^\-]\)-/; /*jslint regexp: false*/ var vendor_prefixes = ['o', 'moz', 'ms', 'webkit']; exports.camelToDashed = function (camel_case) { var match; var dashed = camel_case.replace(camel_to_dashed, '-$&').toLowerCase(); match = dashed.match(first_segment); if (match && vendor_prefixes.indexOf(match[1]) !== -1) { dashed = '-' + dashed; } return dashed; }; CSSStyleDeclaration/lib/CSSStyleDeclaration.js0000644000175000017500000001532612337414256017772 0ustar wmbwmb/********************************************************************* * This is a fork from the CSS Style Declaration part of * https://github.com/NV/CSSOM ********************************************************************/ "use strict"; var CSSOM = require('cssom'); var fs = require('fs'); var path = require('path'); var camelToDashed = require('./parsers').camelToDashed; /** * @constructor * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration */ var CSSStyleDeclaration = function CSSStyleDeclaration() { this._values = {}; this._importants = {}; this._length = 0; }; CSSStyleDeclaration.prototype = { constructor: CSSStyleDeclaration, /** * * @param {string} name * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-getPropertyValue * @return {string} the value of the property if it has been explicitly set for this declaration block. * Returns the empty string if the property has not been set. */ getPropertyValue: function (name) { return this._values[name] || ""; }, /** * * @param {string} name * @param {string} value * @param {string} [priority=null] "important" or null * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-setProperty */ setProperty: function (name, value, priority) { if (value === undefined) { return; } if (value === null || value === '') { this.removeProperty(name); return; } if (this._values[name]) { // Property already exist. Overwrite it. var index = Array.prototype.indexOf.call(this, name); if (index < 0) { this[this._length] = name; this._length++; } } else { // New property. this[this._length] = name; this._length++; } this._values[name] = value; this._importants[name] = priority; }, /** * * @param {string} name * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-removeProperty * @return {string} the value of the property if it has been explicitly set for this declaration block. * Returns the empty string if the property has not been set or the property name does not correspond to a known CSS property. */ removeProperty: function (name) { if (!this._values.hasOwnProperty(name)) { return ""; } var index = Array.prototype.indexOf.call(this, name); if (index < 0) { return ""; } var prevValue = this._values[name]; delete this._values[name]; // That's what WebKit and Opera do Array.prototype.splice.call(this, index, 1); // That's what Firefox does //this[index] = "" return prevValue; }, /** * * @param {String} name */ getPropertyPriority: function (name) { return this._importants[name] || ""; }, getPropertyCSSValue: function () { //FIXME return; }, /** * element.style.overflow = "auto" * element.style.getPropertyShorthand("overflow-x") * -> "overflow" */ getPropertyShorthand: function () { //FIXME return; }, isPropertyImplicit: function () { //FIXME return; }, /** * http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-item */ item: function (index) { index = parseInt(index, 10); if (index < 0 || index >= this._length) { return ''; } return this[index]; } }; Object.defineProperties(CSSStyleDeclaration.prototype, { cssText: { get: function () { var properties = []; var i; var name; var value; var priority; for (i = 0; i < this._length; i++) { name = this[i]; value = this.getPropertyValue(name); priority = this.getPropertyPriority(name); if (priority !== '') { priority = " !" + priority; } properties.push([name, ': ', value, priority, ';'].join('')); } return properties.join(' '); }, set: function (value) { var i; this._values = {}; Array.prototype.splice.call(this, 0, this._length); this._importants = {}; var dummyRule = CSSOM.parse('#bogus{' + value + '}').cssRules[0].style; var rule_length = dummyRule.length; var name; for (i = 0; i < rule_length; ++i) { name = dummyRule[i]; this.setProperty(dummyRule[i], dummyRule.getPropertyValue(name), dummyRule.getPropertyPriority(name)); } }, enumerable: true, configurable: true }, parentRule: { get: function () { return null; }, enumerable: true, configurable: true }, length: { get: function () { return this._length; }, /** * This deletes indices if the new length is less then the current * length. If the new length is more, it does nothing, the new indices * will be undefined until set. **/ set: function (value) { var i; for (i = value; i < this._length; i++) { delete this[i]; } this._length = value; }, enumerable: true, configurable: true } }); var LazyDefinition = function (property, modulePath) { this.get = function () { var definition = require(modulePath).definition; Object.defineProperty(this, property, definition); return this[property]; }; this.set = function (v) { var definition = require(modulePath).definition; Object.defineProperty(this, property, definition); this[property] = v; }; this.enumerable = true; this.configurable = true; }; /* * * http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties */ var property_files = fs.readdirSync(__dirname + '/properties'); property_files.forEach(function (property) { var dashed; if (property.substr(-3) === '.js') { property = path.basename(property, '.js'); dashed = camelToDashed(property); Object.defineProperty(CSSStyleDeclaration.prototype, property, new LazyDefinition(property, './properties/' + property)); Object.defineProperty(CSSStyleDeclaration.prototype, dashed, new LazyDefinition(property, './properties/' + property)); } }); exports.CSSStyleDeclaration = CSSStyleDeclaration; CSSStyleDeclaration/lib/properties/0000755000175000017500000000000012337414256016002 5ustar wmbwmbCSSStyleDeclaration/lib/properties/borderRightWidth.js0000644000175000017500000000057312337414256021620 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderWidth').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-right-width', v); } }, get: function () { return this.getPropertyValue('border-right-width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/paddingBottom.js0000644000175000017500000000040112337414256021126 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('padding-bottom', v); }, get: function () { return this.getPropertyValue('padding-bottom'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderLeftColor.js0000644000175000017500000000057112337414256021432 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderColor').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-left-color', v); } }, get: function () { return this.getPropertyValue('border-left-color'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/listStyle.js0000644000175000017500000000037112337414256020335 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('list-style', v); }, get: function () { return this.getPropertyValue('list-style'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/richness.js0000644000175000017500000000036512337414256020162 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('richness', v); }, get: function () { return this.getPropertyValue('richness'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/marginLeft.js0000644000175000017500000000037312337414256020433 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('margin-left', v); }, get: function () { return this.getPropertyValue('margin-left'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/cue.js0000644000175000017500000000035312337414256017115 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('cue', v); }, get: function () { return this.getPropertyValue('cue'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/azimuth.js0000644000175000017500000000452712337414256020031 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); module.exports.definition = { set: function (v) { var valueType = parsers.valueType(v); if (valueType === parsers.TYPES.ANGLE) { return this.setProperty('azimuth', parsers.parseAngle(v)); } if (valueType === parsers.TYPES.KEYWORD) { var keywords = v.toLowerCase().trim().split(/\s+/); var hasBehind = false; if (keywords.length > 2) { return; } var behindIndex = keywords.indexOf('behind'); hasBehind = (behindIndex !== -1); if (keywords.length === 2) { if (!hasBehind) { return; } keywords.splice(behindIndex, 1); } if (keywords[0] === 'leftwards' || keywords[0] === 'rightwards') { if (hasBehind) { return; } return this.setProperty('azimuth', keywords[0]); } if (keywords[0] === 'behind') { return this.setProperty('azimuth', '180deg'); } var deg; switch (keywords[0]) { case 'left-side': return this.setProperty('azimuth', '270deg'); case 'far-left': return this.setProperty('azimuth', (hasBehind ? 240 : 300) + 'deg'); case 'left': return this.setProperty('azimuth', (hasBehind ? 220 : 320) + 'deg'); case 'center-left': return this.setProperty('azimuth', (hasBehind ? 200 : 340) + 'deg'); case 'center': return this.setProperty('azimuth', (hasBehind ? 180 : 0) + 'deg'); case 'center-right': return this.setProperty('azimuth', (hasBehind ? 160 : 20) + 'deg'); case 'right': return this.setProperty('azimuth', (hasBehind ? 140 : 40) + 'deg'); case 'far-right': return this.setProperty('azimuth', (hasBehind ? 120 : 60) + 'deg'); case 'right-side': return this.setProperty('azimuth', '90deg'); default: return; } } }, get: function () { return this.getPropertyValue('azimuth'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/voiceFamily.js0000644000175000017500000000037412337414256020613 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('voic-family', v); }, get: function () { return this.getPropertyValue('voice-family'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/paddingTop.js0000644000175000017500000000037312337414256020434 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('padding-top', v); }, get: function () { return this.getPropertyValue('padding-top'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderRightStyle.js0000644000175000017500000000057312337414256021641 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderStyle').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-right-style', v); } }, get: function () { return this.getPropertyValue('border-right-style'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/paddingRight.js0000644000175000017500000000037712337414256020753 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('padding-right', v); }, get: function () { return this.getPropertyValue('padding-right'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/cursor.js0000644000175000017500000000036112337414256017655 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('cursor', v); }, get: function () { return this.getPropertyValue('cursor'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/wordSpacing.js0000644000175000017500000000037512337414256020625 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('word-spacing', v); }, get: function () { return this.getPropertyValue('word-spacing'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/color.js0000644000175000017500000000045712337414256017464 0ustar wmbwmb'use strict'; var parseColor = require('../parsers').parseColor; module.exports.definition = { set: function (v) { this.setProperty('color', parseColor(v)); }, get: function () { return this.getPropertyValue('color'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/playDuring.js0000644000175000017500000000037312337414256020461 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('play-during', v); }, get: function () { return this.getPropertyValue('play-during'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/listStyleImage.js0000644000175000017500000000040512337414256021276 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('list-style-image', v); }, get: function () { return this.getPropertyValue('list-style-image'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/outlineColor.js0000644000175000017500000000047712337414256021026 0ustar wmbwmb'use strict'; var parseColor = require('../parsers').parseColor; module.exports.definition = { set: function (v) { this.setProperty('outline-color', parseColor(v)); }, get: function () { return this.getPropertyValue('outline-color'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/padding.js0000644000175000017500000000036312337414256017750 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('padding', v); }, get: function () { return this.getPropertyValue('padding'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/pause.js0000644000175000017500000000035712337414256017462 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('pause', v); }, get: function () { return this.getPropertyValue('pause'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/overflow.js0000644000175000017500000000036512337414256020207 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('overflow', v); }, get: function () { return this.getPropertyValue('overflow'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/quotes.js0000644000175000017500000000036112337414256017660 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('quotes', v); }, get: function () { return this.getPropertyValue('quotes'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/textAlign.js0000644000175000017500000000037112337414256020300 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('text-align', v); }, get: function () { return this.getPropertyValue('text-align'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderBottomWidth.js0000644000175000017500000000057512337414256022011 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderWidth').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-bottom-width', v); } }, get: function () { return this.getPropertyValue('border-bottom-width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/marks.js0000644000175000017500000000035712337414256017462 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('marks', v); }, get: function () { return this.getPropertyValue('marks'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/outlineStyle.js0000644000175000017500000000037712337414256021047 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('outline-style', v); }, get: function () { return this.getPropertyValue('outline-style'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/pauseAfter.js0000644000175000017500000000037312337414256020442 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('pause-after', v); }, get: function () { return this.getPropertyValue('pause-after'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderBottomStyle.js0000644000175000017500000000057512337414256022032 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderStyle').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-bottom-style', v); } }, get: function () { return this.getPropertyValue('border-bottom-style'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderLeft.js0000644000175000017500000000153112337414256020430 0ustar wmbwmb'use strict'; var shorthandParser = require('../parsers').shorthandParser; var shorthand_for = { borderLeftWidth: require('./borderLeftWidth'), borderLeftStyle: require('./borderLeftStyle'), borderLeftColor: require('./borderLeftColor') }; var isValid = module.exports.isValid = function isValid(v) { return shorthandParser(v, shorthand_for) !== undefined; }; module.exports.definition = { set: function (v) { var obj = shorthandParser(v, shorthand_for); if (obj === undefined) { return; } Object.keys(obj).forEach(function (property) { this._values[property] = obj[property]; }, this); this.setProperty('border-left', v); }, get: function () { return this.getPropertyValue('border-left'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/left.js0000644000175000017500000000047712337414256017302 0ustar wmbwmb'use strict'; var parseMeasurement = require('../parsers').parseMeasurement; module.exports.definition = { set: function (v) { this.setProperty('left', parseMeasurement(v)); }, get: function () { return this.getPropertyValue('left'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/height.js0000644000175000017500000000050312337414256017606 0ustar wmbwmb'use strict'; var parseMeasurement = require('../parsers').parseMeasurement; module.exports.definition = { set: function (v) { this.setProperty('height', parseMeasurement(v)); }, get: function () { return this.getPropertyValue('height'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderTopStyle.js0000644000175000017500000000056712337414256021331 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderStyle').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-top-style', v); } }, get: function () { return this.getPropertyValue('border-top-style'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/textTransform.js0000644000175000017500000000040112337414256021213 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('text-transform', v); }, get: function () { return this.getPropertyValue('text-transform'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/clear.js0000644000175000017500000000061312337414256017426 0ustar wmbwmb'use strict'; var parseKeyword = require('../parsers').parseKeyword; var clear_keywords = [ 'none', 'left', 'right', 'both', 'inherit' ]; module.exports.definition = { set: function (v) { this.setProperty('clear', parseKeyword(v, clear_keywords)); }, get: function () { return this.getPropertyValue('clear'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderRadius.js0000644000175000017500000000037712337414256020774 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('border-radius', v); }, get: function () { return this.getPropertyValue('border-radius'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/pageBreakBefore.js0000644000175000017500000000040712337414256021345 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('page-break-before', v); }, get: function () { return this.getPropertyValue('page-break-before'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/opacity.js0000644000175000017500000000046612337414256020016 0ustar wmbwmb'use strict'; var parseNumber = require('../parsers').parseNumber; module.exports.definition = { set: function (v) { this.setProperty('opacity', parseNumber(v)); }, get: function () { return this.getPropertyValue('opacity'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/stress.js0000644000175000017500000000036112337414256017663 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('stress', v); }, get: function () { return this.getPropertyValue('stress'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/fontStyle.js0000644000175000017500000000063612337414256020334 0ustar wmbwmb'use strict'; var valid_styles = ['normal', 'italic', 'oblique', 'inherit']; module.exports.isValid = function (v) { return valid_styles.indexOf(v.toLowerCase()) !== -1; }; module.exports.definition = { set: function (v) { this.setProperty('font-style', v); }, get: function () { return this.getPropertyValue('font-style'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/pitchRange.js0000644000175000017500000000037312337414256020427 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('pitch-range', v); }, get: function () { return this.getPropertyValue('pitch-range'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderRightColor.js0000644000175000017500000000057312337414256021617 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderColor').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-right-color', v); } }, get: function () { return this.getPropertyValue('border-right-color'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/pauseBefore.js0000644000175000017500000000037512337414256020605 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('pause-before', v); }, get: function () { return this.getPropertyValue('pause-before'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/orphans.js0000644000175000017500000000036312337414256020014 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('orphans', v); }, get: function () { return this.getPropertyValue('orphans'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderTopColor.js0000644000175000017500000000056712337414256021307 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderColor').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-top-color', v); } }, get: function () { return this.getPropertyValue('border-top-color'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/backgroundPosition.js0000644000175000017500000000303712337414256022207 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); var valid_keywords = ['top', 'center', 'bottom', 'left', 'right']; var parse = function parse(v) { var parts = v.split(/\s+/); if (parts.length > 2 || parts.length < 1) { return undefined; } var types = []; parts.forEach(function (part, index) { types[index] = parsers.valueType(part); }); if (parts.length === 1) { if (types[0] === parsers.TYPES.LENGTH || types[0] === parsers.TYPES.PERCENT) { return v; } if (types[0] === parsers.TYPES.KEYWORD) { if (valid_keywords.indexOf(v.toLowerCase()) !== -1 || v.toLowerCase() === 'inherit') { return v; } } return undefined; } if ((types[0] === parsers.TYPES.LENGTH || types[0] === parsers.TYPES.PERCENT) && (types[1] === parsers.TYPES.LENGTH || types[1] === parsers.TYPES.PERCENT)) { return v; } if (types[0] !== parsers.TYPES.KEYWORD || types[1] !== parsers.TYPES.KEYWORD) { return undefined; } if (valid_keywords.indexOf(parts[0]) !== -1 && valid_keywords.indexOf(parts[1]) !== -1) { return v; } return undefined; }; module.exports.isValid = function isValid(v) { return parse(v) !== undefined; }; module.exports.definition = { set: function (v) { this.setProperty('background-position', parse(v)); }, get: function () { return this.getPropertyValue('background-position'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/counterReset.js0000644000175000017500000000037712337414256021031 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('counter-reset', v); }, get: function () { return this.getPropertyValue('counter-reset'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/speakNumeral.js0000644000175000017500000000037712337414256020776 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('speak-numeral', v); }, get: function () { return this.getPropertyValue('speak-numeral'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderTop.js0000644000175000017500000000152112337414256020277 0ustar wmbwmb'use strict'; var shorthandParser = require('../parsers').shorthandParser; var shorthand_for = { borderTopWidth: require('./borderTopWidth'), borderTopStyle: require('./borderTopStyle'), borderTopColor: require('./borderTopColor') }; var isValid = module.exports.isValid = function isValid(v) { return shorthandParser(v, shorthand_for) !== undefined; }; module.exports.definition = { set: function (v) { var obj = shorthandParser(v, shorthand_for); if (obj === undefined) { return; } Object.keys(obj).forEach(function (property) { this._values[property] = obj[property]; }, this); this.setProperty('border-top', v); }, get: function () { return this.getPropertyValue('border-top'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderBottomColor.js0000644000175000017500000000057512337414256022010 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderColor').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-bottom-color', v); } }, get: function () { return this.getPropertyValue('border-bottom-color'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/pageBreakAfter.js0000644000175000017500000000040512337414256021202 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('page-break-after', v); }, get: function () { return this.getPropertyValue('page-break-after'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/outline.js0000644000175000017500000000036312337414256020021 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('outline', v); }, get: function () { return this.getPropertyValue('outline'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/textShadow.js0000644000175000017500000000037312337414256020475 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('text-shadow', v); }, get: function () { return this.getPropertyValue('text-shadow'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/width.js0000644000175000017500000000050112337414256017453 0ustar wmbwmb'use strict'; var parseMeasurement = require('../parsers').parseMeasurement; module.exports.definition = { set: function (v) { this.setProperty('width', parseMeasurement(v)); }, get: function () { return this.getPropertyValue('width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/fontFamily.js0000644000175000017500000000127212337414256020452 0ustar wmbwmb'use strict'; var TYPES = require('../parsers').TYPES; var valueType = require('../parsers').valueType; var partsRegEx = /\s*,\s*/; module.exports.isValid = function isValid(v) { var parts = v.split(partsRegEx); var len = parts.len; var i; var type; for (i = 0; i < len; i++) { type = valueType(parts[i]); if (type === TYPES.STRING || type === TYPES.KEYWORD) { return true; } } return false; }; module.exports.definition = { set: function (v) { this.setProperty('font-family', v); }, get: function () { return this.getPropertyValue('font-family'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/speechRate.js0000644000175000017500000000037312337414256020426 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('speech-rate', v); }, get: function () { return this.getPropertyValue('speech-rate'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/speakHeader.js0000644000175000017500000000037512337414256020561 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('speak-header', v); }, get: function () { return this.getPropertyValue('speak-header'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/outlineOffset.js0000644000175000017500000000040112337414256021161 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('outline-offset', v); }, get: function () { return this.getPropertyValue('outline-offset'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/backgroundAttachment.js0000644000175000017500000000112412337414256022466 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); var isValid = module.exports.isValid = function isValid(v) { return parsers.valueType(v) === parsers.TYPES.KEYWORD && (v.toLowerCase() === 'scroll' || v.toLowerCase() === 'fixed' || v.toLowerCase() === 'inherit'); }; module.exports.definition = { set: function (v) { if (!isValid(v)) { return; } this.setProperty('background-attachment', v); }, get: function () { return this.getPropertyValue('background-attachment'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/widows.js0000644000175000017500000000036112337414256017654 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('widows', v); }, get: function () { return this.getPropertyValue('widows'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/textDecoration.js0000644000175000017500000000040312337414256021331 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('text-decoration', v); }, get: function () { return this.getPropertyValue('text-decoration'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderLeftWidth.js0000644000175000017500000000057112337414256021433 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderWidth').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-left-width', v); } }, get: function () { return this.getPropertyValue('border-left-width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/marginBottom.js0000644000175000017500000000037712337414256021011 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('margin-bottom', v); }, get: function () { return this.getPropertyValue('margin-bottom'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/lineHeight.js0000644000175000017500000000114412337414256020420 0ustar wmbwmb'use strict'; var TYPES = require('../parsers').TYPES; var valueType = require('../parsers').valueType; module.exports.isValid = function isValid(v) { var type = valueType(v); return (type === TYPES.KEYWORD && (v.toLowerCase() === 'normal') || (v.toLowerCase() === 'inherit')) || type === TYPES.NUMBER || type === TYPES.LENGTH || type === TYPES.PERCENT; }; module.exports.definition = { set: function (v) { this.setProperty('line-height', v); }, get: function () { return this.getPropertyValue('line-height'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderRight.js0000644000175000017500000000154112337414256020614 0ustar wmbwmb'use strict'; var shorthandParser = require('../parsers').shorthandParser; var shorthand_for = { borderRightWidth: require('./borderRightWidth'), borderRightStyle: require('./borderRightStyle'), borderRightColor: require('./borderRightColor') }; var isValid = module.exports.isValid = function isValid(v) { return shorthandParser(v, shorthand_for) !== undefined; }; module.exports.definition = { set: function (v) { var obj = shorthandParser(v, shorthand_for); if (obj === undefined) { return; } Object.keys(obj).forEach(function (property) { this._values[property] = obj[property]; }, this); this.setProperty('border-right', v); }, get: function () { return this.getPropertyValue('border-right'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/bottom.js0000644000175000017500000000050312337414256017642 0ustar wmbwmb'use strict'; var parseMeasurement = require('../parsers').parseMeasurement; module.exports.definition = { set: function (v) { this.setProperty('bottom', parseMeasurement(v)); }, get: function () { return this.getPropertyValue('bottom'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/speak.js0000644000175000017500000000035712337414256017450 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('speak', v); }, get: function () { return this.getPropertyValue('speak'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/fontWeight.js0000644000175000017500000000076012337414256020461 0ustar wmbwmb'use strict'; var valid_weights = ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900', 'inherit']; module.exports.isValid = function isValid(v) { return valid_weights.indexOf(v.toLowerCase()) !== -1; }; module.exports.definition = { set: function (v) { this.setProperty('font-weight', v); }, get: function () { return this.getPropertyValue('font-weight'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/maxWidth.js0000644000175000017500000000036712337414256020133 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('max-width', v); }, get: function () { return this.getPropertyValue('max-width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/outlineWidth.js0000644000175000017500000000037712337414256021026 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('outline-width', v); }, get: function () { return this.getPropertyValue('outline-width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/margin.js0000644000175000017500000000036112337414256017615 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('margin', v); }, get: function () { return this.getPropertyValue('margin'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderStyle.js0000644000175000017500000000127412337414256020642 0ustar wmbwmb'use strict'; var implicitSetter = require('../parsers').implicitSetter; // the valid border-styles: var styles = ['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset']; module.exports.isValid = function parse(v) { return typeof v === 'string' && styles.indexOf(v) !== -1; }; var isValid = module.exports.isValid; var parser = function (v) { if (isValid(v)) { return v.toLowerCase(); } return undefined; }; module.exports.definition = { set: implicitSetter('border', 'style', isValid, parser), get: function () { return this.getPropertyValue('border-style'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/fontSizeAdjust.js0000644000175000017500000000040512337414256021313 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('font-size-adjust', v); }, get: function () { return this.getPropertyValue('font-size-adjust'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/backgroundColor.js0000644000175000017500000000144012337414256021455 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); var parse = function parse(v) { var parsed = parsers.parseColor(v); if (parsed !== undefined) { return parsed; } if (parsers.valueType(v) === parsers.TYPES.KEYWORD && (v.toLowerCase() === 'transparent' || v.toLowerCase() === 'inherit')) { return v; } return undefined; }; module.exports.isValid = function isValid(v) { return parse(v) !== undefined; }; module.exports.definition = { set: function (v) { var parsed = parse(v); if (parsed === undefined) { return; } this.setProperty('background-color', parsed); }, get: function () { return this.getPropertyValue('background-color'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/visibility.js0000644000175000017500000000037112337414256020530 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('visibility', v); }, get: function () { return this.getPropertyValue('visibility'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/direction.js0000644000175000017500000000036712337414256020326 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('direction', v); }, get: function () { return this.getPropertyValue('direction'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/counterIncrement.js0000644000175000017500000000040712337414256021665 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('counter-increment', v); }, get: function () { return this.getPropertyValue('counter-increment'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderBottom.js0000644000175000017500000000155112337414256021004 0ustar wmbwmb'use strict'; var shorthandParser = require('../parsers').shorthandParser; var shorthand_for = { borderBottomWidth: require('./borderBottomWidth'), borderBottomStyle: require('./borderBottomStyle'), borderBottomColor: require('./borderBottomColor') }; var isValid = module.exports.isValid = function isValid(v) { return shorthandParser(v, shorthand_for) !== undefined; }; module.exports.definition = { set: function (v) { var obj = shorthandParser(v, shorthand_for); if (obj === undefined) { return; } Object.keys(obj).forEach(function (property) { this._values[property] = obj[property]; }, this); this.setProperty('border-bottom', v); }, get: function () { return this.getPropertyValue('border-bottom'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/cssFloat.js0000644000175000017500000000035712337414256020123 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('float', v); }, get: function () { return this.getPropertyValue('float'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/fontSize.js0000644000175000017500000000143312337414256020142 0ustar wmbwmb'use strict'; var TYPES = require('../parsers').TYPES; var valueType = require('../parsers').valueType; var absoluteSizes = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large']; var relativeSizes = ['larger', 'smaller']; module.exports.isValid = function (v) { var type = valueType(v.toLowerCase()); return type === TYPES.LENGTH || type === TYPES.PERCENT || (type === TYPES.KEYWORD && absoluteSizes.indexOf(v.toLowerCase()) !== -1) || (type === TYPES.KEYWORD && relativeSizes.indexOf(v.toLowerCase()) !== -1); }; module.exports.definition = { set: function (v) { this.setProperty('font-size', v); }, get: function () { return this.getPropertyValue('font-size'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/unicodeBidi.js0000644000175000017500000000037512337414256020563 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('unicode-bidi', v); }, get: function () { return this.getPropertyValue('unicode-bidi'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/maxHeight.js0000644000175000017500000000037112337414256020257 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('max-height', v); }, get: function () { return this.getPropertyValue('max-height'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/position.js0000644000175000017500000000036512337414256020210 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('position', v); }, get: function () { return this.getPropertyValue('position'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/display.js0000644000175000017500000000036312337414256020007 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('display', v); }, get: function () { return this.getPropertyValue('display'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/background.js0000644000175000017500000000145312337414256020462 0ustar wmbwmb'use strict'; var shorthandParser = require('../parsers').shorthandParser; var shorthandSetter = require('../parsers').shorthandSetter; var shorthandGetter = require('../parsers').shorthandGetter; var shorthand_for = { 'background-color': require('./backgroundColor'), 'background-image': require('./backgroundImage'), 'background-repeat': require('./backgroundRepeat'), 'background-attachment': require('./backgroundAttachment'), 'background-position': require('./backgroundPosition') }; module.exports.isValid = function isValid(v) { return shorthandParser(v, shorthand_for) !== undefined; }; module.exports.definition = { set: shorthandSetter('background', shorthand_for), get: shorthandGetter('background', shorthand_for), enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/volume.js0000644000175000017500000000036112337414256017647 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('volume', v); }, get: function () { return this.getPropertyValue('volume'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/whiteSpace.js0000644000175000017500000000037312337414256020437 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('white-space', v); }, get: function () { return this.getPropertyValue('white-space'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/border.js0000644000175000017500000000121512337414256017614 0ustar wmbwmb'use strict'; var shorthandParser = require('../parsers').shorthandParser; var shorthandSetter = require('../parsers').shorthandSetter; var shorthandGetter = require('../parsers').shorthandGetter; var shorthand_for = { 'border-width': require('./borderWidth'), 'border-style': require('./borderStyle'), 'border-color': require('./borderColor') }; module.exports.isValid = function isValid(v) { return shorthandParser(v, shorthand_for) !== undefined; }; module.exports.definition = { set: shorthandSetter('border', shorthand_for), get: shorthandGetter('border', shorthand_for), enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/page.js0000644000175000017500000000035512337414256017257 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('page', v); }, get: function () { return this.getPropertyValue('page'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/verticalAlign.js0000644000175000017500000000040112337414256021117 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('vertical-align', v); }, get: function () { return this.getPropertyValue('vertical-align'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/right.js0000644000175000017500000000050112337414256017451 0ustar wmbwmb'use strict'; var parseMeasurement = require('../parsers').parseMeasurement; module.exports.definition = { set: function (v) { this.setProperty('right', parseMeasurement(v)); }, get: function () { return this.getPropertyValue('right'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/content.js0000644000175000017500000000036312337414256020014 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('content', v); }, get: function () { return this.getPropertyValue('content'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/letterSpacing.js0000644000175000017500000000040112337414256021137 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('letter-spacing', v); }, get: function () { return this.getPropertyValue('letter-spacing'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/marginRight.js0000644000175000017500000000037512337414256020620 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('margin-right', v); }, get: function () { return this.getPropertyValue('margin-right'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/pageBreakInside.js0000644000175000017500000000040712337414256021356 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('page-break-inside', v); }, get: function () { return this.getPropertyValue('page-break-inside'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/font.js0000644000175000017500000000256312337414256017314 0ustar wmbwmb'use strict'; var TYPES = require('../parsers').TYPES; var valueType = require('../parsers').valueType; var shorthandParser = require('../parsers').shorthandParser; var shorthandSetter = require('../parsers').shorthandSetter; var shorthandGetter = require('../parsers').shorthandGetter; var shorthand_for = { 'font-family': require('./fontFamily'), 'font-size': require('./fontSize'), 'font-style': require('./fontStyle'), 'font-variant': require('./fontVariant'), 'font-weight': require('./fontWeight'), 'line-height': require('./lineHeight') }; var static_fonts = ['caption', 'icon', 'menu', 'message-box', 'small-caption', 'status-bar', 'inherit']; module.exports.isValid = function isValid(v) { return (shorthandParser(v, shorthand_for) !== undefined) || (valueType(v) === TYPES.KEYWORD && static_fonts.indexOf(v.toLowerCase()) !== -1); }; var setter = shorthandSetter('background', shorthand_for); module.exports.definition = { set: function (v) { var short = shorthandParser(v, shorthand_for); if (short !== undefined) { return setter.call(this, v); } if (valueType(v) === TYPES.KEYWORD && static_fonts.indexOf(v.toLowerCase()) !== -1) { this.setProperty('font', v); } }, get: shorthandGetter('background', shorthand_for), enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/fontVariant.js0000644000175000017500000000064612337414256020641 0ustar wmbwmb'use strict'; var valid_variants = ['normal', 'small-caps', 'inherit']; module.exports.isValid = function isValid(v) { return valid_variants.indexOf(v.toLowerCase()) !== -1; }; module.exports.definition = { set: function (v) { this.setProperty('font-variant', v); }, get: function () { return this.getPropertyValue('font-variant'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderTopWidth.js0000644000175000017500000000056712337414256021310 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderWidth').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-top-width', v); } }, get: function () { return this.getPropertyValue('border-top-width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/listStylePosition.js0000644000175000017500000000041312337414256022057 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('list-style-position', v); }, get: function () { return this.getPropertyValue('list-style-position'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderSpacing.js0000644000175000017500000000167012337414256021126 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); // ? | inherit // if one, it applies to both horizontal and verical spacing // if two, the first applies to the horizontal and the second applies to vertical spacing var parse = function parse(v) { if (v.toLowerCase() === 'inherit') { return v; } var parts = v.split(/\s+/); if (parts.length !== 1 && parts.length !== 2) { return undefined; } parts.forEach(function (part) { if (parsers.valueType(part) !== parsers.TYPES.LENGTH) { return undefined; } }); return v; }; module.exports.isValid = function isValid(v) { return parse(v) !== undefined; }; module.exports.definition = { set: function (v) { this.setProperty('border-spacing', parse(v)); }, get: function () { return this.getPropertyValue('border-spacing'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/minWidth.js0000644000175000017500000000036712337414256020131 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('min-width', v); }, get: function () { return this.getPropertyValue('min-width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/textIndent.js0000644000175000017500000000037312337414256020471 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('text-indent', v); }, get: function () { return this.getPropertyValue('text-indent'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/clip.js0000644000175000017500000000222612337414256017271 0ustar wmbwmb'use strict'; var parseMeasurement = require('../parsers').parseMeasurement; /*jslint regexp: true*/ var shape_regex = /^rect\((.*)\)$/i; /*jslint regexp: false*/ var parse = function (val) { if (val === '' || val === null) { return val; } if (typeof val !== 'string') { return undefined; } val = val.toLowerCase(); if (val === 'auto' || val === 'inherit') { return val; } var matches = val.match(shape_regex); if (!matches) { return undefined; } var parts = matches[1].split(/\s*,\s*/); if (parts.length !== 4) { return undefined; } var valid = parts.every(function (part, index) { var measurement = parseMeasurement(part); parts[index] = measurement; return measurement !== undefined; }); if (!valid) { return undefined; } parts = parts.join(', '); return val.replace(matches[1], parts); }; module.exports.definition = { set: function (v) { this.setProperty('clip', parse(v)); }, get: function () { return this.getPropertyValue('clip'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/cueBefore.js0000644000175000017500000000037112337414256020240 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('cue-before', v); }, get: function () { return this.getPropertyValue('cue-before'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/cueAfter.js0000644000175000017500000000036712337414256020104 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('cue-after', v); }, get: function () { return this.getPropertyValue('cue-after'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/backgroundImage.js0000644000175000017500000000127012337414256021422 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); var parse = function parse(v) { var parsed = parsers.parseUrl(v); if (parsed !== undefined) { return parsed; } if (parsers.valueType(v) === parsers.TYPES.KEYWORD && (v.toLowerCase() === 'none' || v.toLowerCase() === 'inherit')) { return v; } return undefined; }; module.exports.isValid = function isValid(v) { return parse(v) !== undefined; }; module.exports.definition = { set: function (v) { this.setProperty('background-image', parse(v)); }, get: function () { return this.getPropertyValue('background-image'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderLeftStyle.js0000644000175000017500000000057112337414256021454 0ustar wmbwmb'use strict'; var isValid = module.exports.isValid = require('./borderStyle').isValid; module.exports.definition = { set: function (v) { if (isValid(v)) { this.setProperty('border-left-style', v); } }, get: function () { return this.getPropertyValue('border-left-style'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/marginTop.js0000644000175000017500000000037112337414256020301 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('margin-top', v); }, get: function () { return this.getPropertyValue('margin-top'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/speakPunctuation.js0000644000175000017500000000040712337414256021676 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('speak-punctuation', v); }, get: function () { return this.getPropertyValue('speak-punctuation'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/minHeight.js0000644000175000017500000000037112337414256020255 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('min-height', v); }, get: function () { return this.getPropertyValue('min-height'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderCollapse.js0000644000175000017500000000117112337414256021300 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); var parse = function parse(v) { if (parsers.valueType(v) === parsers.TYPES.KEYWORD && (v.toLowerCase() === 'collapse' || v.toLowerCase() === 'separate' || v.toLowerCase() === 'inherit')) { return v; } return undefined; }; module.exports.isValid = function isValid(v) { return parse(v) !== undefined; }; module.exports.definition = { set: function (v) { this.setProperty('border-collapse', parse(v)); }, get: function () { return this.getPropertyValue('border-collapse'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/captionSide.js0000644000175000017500000000037512337414256020607 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('caption-side', v); }, get: function () { return this.getPropertyValue('caption-side'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/elevation.js0000644000175000017500000000036712337414256020334 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('elevation', v); }, get: function () { return this.getPropertyValue('elevation'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/fontStretch.js0000644000175000017500000000037512337414256020650 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('font-stretch', v); }, get: function () { return this.getPropertyValue('font-stretch'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/backgroundRepeat.js0000644000175000017500000000130012337414256021612 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); var parse = function parse(v) { if (parsers.valueType(v) === parsers.TYPES.KEYWORD && (v.toLowerCase() === 'repeat' || v.toLowerCase() === 'repeat-x' || v.toLowerCase() === 'repeat-y' || v.toLowerCase() === 'no-repeat' || v.toLowerCase() === 'inherit')) { return v; } return undefined; }; module.exports.isValid = function isValid(v) { return parse(v) !== undefined; }; module.exports.definition = { set: function (v) { this.setProperty('background-repeat', parse(v)); }, get: function () { return this.getPropertyValue('background-repeat'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderColor.js0000644000175000017500000000126512337414256020620 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); var implicitSetter = require('../parsers').implicitSetter; module.exports.isValid = function parse(v) { if (typeof v !== 'string') { return false; } return (v.toLowerCase() === 'transparent' || parsers.valueType(v) === parsers.TYPES.COLOR); }; var isValid = module.exports.isValid; var parser = function (v) { if (isValid(v)) { return v.toLowerCase(); } return undefined; }; module.exports.definition = { set: implicitSetter('border', 'color', isValid, parser), get: function () { return this.getPropertyValue('border-color'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/emptyCells.js0000644000175000017500000000037312337414256020464 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('empty-cells', v); }, get: function () { return this.getPropertyValue('empty-cells'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/zIndex.js0000644000175000017500000000036312337414256017603 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('z-index', v); }, get: function () { return this.getPropertyValue('z-index'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/top.js0000644000175000017500000000047512337414256017150 0ustar wmbwmb'use strict'; var parseMeasurement = require('../parsers').parseMeasurement; module.exports.definition = { set: function (v) { this.setProperty('top', parseMeasurement(v)); }, get: function () { return this.getPropertyValue('top'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/size.js0000644000175000017500000000035512337414256017315 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('size', v); }, get: function () { return this.getPropertyValue('size'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/tableLayout.js0000644000175000017500000000037512337414256020632 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('table-layout', v); }, get: function () { return this.getPropertyValue('table-layout'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/borderWidth.js0000644000175000017500000000176512337414256020626 0ustar wmbwmb'use strict'; var parsers = require('../parsers'); var parsers = require('../parsers'); var implicitSetter = require('../parsers').implicitSetter; // the valid border-widths: var widths = ['thin', 'medium', 'thick']; module.exports.isValid = function parse(v) { var length = parsers.parseLength(v); if (length !== undefined) { return true; } if (typeof v !== 'string') { return false; } v = v.toLowerCase(); if (widths.indexOf(v) === -1) { return false; } return true; }; var isValid = module.exports.isValid; var parser = function (v) { var length = parsers.parseLength(v); if (length !== undefined) { return length; } if (isValid(v)) { return v.toLowerCase(); } return undefined; }; module.exports.definition = { set: implicitSetter('border', 'width', isValid, parser), get: function () { return this.getPropertyValue('border-width'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/pitch.js0000644000175000017500000000035712337414256017454 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('pitch', v); }, get: function () { return this.getPropertyValue('pitch'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/listStyleType.js0000644000175000017500000000040312337414256021173 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('list-style-type', v); }, get: function () { return this.getPropertyValue('list-style-type'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/paddingLeft.js0000644000175000017500000000037512337414256020566 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('padding-left', v); }, get: function () { return this.getPropertyValue('padding-left'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/lib/properties/markerOffset.js0000644000175000017500000000037712337414256020777 0ustar wmbwmb'use strict'; module.exports.definition = { set: function (v) { this.setProperty('marker-offset', v); }, get: function () { return this.getPropertyValue('marker-offset'); }, enumerable: true, configurable: true }; CSSStyleDeclaration/tests/0000755000175000017500000000000012337414256014202 5ustar wmbwmbCSSStyleDeclaration/tests/tests.js0000644000175000017500000002774712337414256015723 0ustar wmbwmb"use strict"; var util = require('util'); var cssstyle = require('../lib/CSSStyleDeclaration'); var camelToDashed = require('../lib/parsers').camelToDashed; /** * These are the required properties * see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties **/ var properties = [ 'azimuth', 'background', 'backgroundAttachment', 'backgroundColor', 'backgroundImage', 'backgroundPosition', 'backgroundRepeat', 'border', 'borderCollapse', 'borderColor', 'borderSpacing', 'borderStyle', 'borderTop', 'borderRight', 'borderBottom', 'borderLeft', 'borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor', 'borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderWidth', 'bottom', 'captionSide', 'clear', 'clip', 'color', 'content', 'counterIncrement', 'counterReset', 'cue', 'cueAfter', 'cueBefore', 'cursor', 'direction', 'display', 'elevation', 'emptyCells', 'cssFloat', 'font', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontWeight', 'height', 'left', 'letterSpacing', 'lineHeight', 'listStyle', 'listStyleImage', 'listStylePosition', 'listStyleType', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'markerOffset', 'marks', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'orphans', 'outline', 'outlineColor', 'outlineStyle', 'outlineWidth', 'overflow', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'page', 'pageBreakAfter', 'pageBreakBefore', 'pageBreakInside', 'pause', 'pauseAfter', 'pauseBefore', 'pitch', 'pitchRange', 'playDuring', 'position', 'quotes', 'richness', 'right', 'size', 'speak', 'speakHeader', 'speakNumeral', 'speakPunctuation', 'speechRate', 'stress', 'tableLayout', 'textAlign', 'textDecoration', 'textIndent', 'textShadow', 'textTransform', 'top', 'unicodeBidi', 'verticalAlign', 'visibility', 'voiceFamily', 'volume', 'whiteSpace', 'widows', 'width', 'wordSpacing', 'zIndex']; var dashed_properties = properties.map(function (property) { return camelToDashed(property); }); module.exports = { 'Verify Has Properties': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(properties.length * 2); properties.forEach(function (property) { test.ok(style.__lookupGetter__(property), 'missing ' + property + ' property'); test.ok(style.__lookupSetter__(property), 'missing ' + property + ' property'); }); test.done(); }, 'Verify Has Dashed Properties': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(dashed_properties.length * 2); dashed_properties.forEach(function (property) { test.ok(style.__lookupGetter__(property), 'missing ' + property + ' property'); test.ok(style.__lookupSetter__(property), 'missing ' + property + ' property'); }); test.done(); }, 'Verify Has Functions': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(6); test.ok(typeof style.getPropertyValue === 'function', 'missing getPropertyValue()'); test.ok(typeof style.getPropertyCSSValue === 'function', 'missing getPropertyCSSValue()'); test.ok(typeof style.removeProperty === 'function', 'missing removeProperty()'); test.ok(typeof style.getPropertyPriority === 'function', 'missing getPropertyPriority()'); test.ok(typeof style.setProperty === 'function', 'missing setProperty()'); test.ok(typeof style.item === 'function', 'missing item()'); test.done(); }, 'Verify Has Special Properties': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(5); test.ok(style.__lookupGetter__('cssText'), 'missing cssText getter'); test.ok(style.__lookupSetter__('cssText'), 'missing cssText setter'); test.ok(style.__lookupGetter__('length'), 'missing length getter'); test.ok(style.__lookupSetter__('length'), 'missing length setter'); test.ok(style.__lookupGetter__('parentRule'), 'missing parentRule getter'); test.done(); }, 'Test From Style String': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(8); style.cssText = 'color: blue; background-color: red; width: 78%'; test.ok(3 === style.length, 'length is not 3'); test.ok('color: blue; background-color: red; width: 78%;' === style.cssText, 'cssText is wrong'); test.ok('blue' === style.getPropertyValue('color'), "getPropertyValue('color') failed"); test.ok('color' === style.item(0), 'item(0) failed'); test.ok('background-color' === style[1], 'style[1] failed'); test.ok('red' === style.backgroundColor, 'style.backgroundColor failed with "' + style.backgroundColor + '"'); style.cssText = ''; test.ok('' === style.cssText, 'cssText is not empty'); test.ok(0 === style.length, 'length is not 0'); test.done(); }, 'Test From Properties': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(11); style.color = 'blue'; test.ok(1 === style.length, 'length is not 1'); test.ok('color' === style[0], 'style[0] is not color'); test.ok('color: blue;' === style.cssText, 'cssText is wrong'); test.ok('color' === style.item(0), 'item(0) is not color'); test.ok('blue' === style.color, 'color is not blue'); style.backgroundColor = 'red'; test.ok(2 === style.length, 'length is not 2'); test.ok('color' === style[0], 'style[0] is not color'); test.ok('background-color' === style[1], 'style[1] is not background-color'); test.ok('color: blue; background-color: red;' === style.cssText, 'cssText is wrong'); test.ok('red' === style.backgroundColor, 'backgroundColor is not red'); style.removeProperty('color'); test.ok('background-color' === style[0], 'style[0] is not background-color'); test.done(); }, 'Test Shorthand Properties': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(11); style.background = 'blue url(http://www.example.com/some_img.jpg)'; test.ok('blue' === style.backgroundColor, 'backgroundColor is not blue'); test.ok('url(http://www.example.com/some_img.jpg)' === style.backgroundImage, 'backgroundImage is wrong'); test.ok('blue url(http://www.example.com/some_img.jpg)' === style.background, 'background is different'); style.border = '0 solid black'; test.ok('0px', style.borderWidth, 'borderWidth is not 0px'); test.ok('solid', style.borderStyle, 'borderStyle is not solid'); test.ok('black', style.borderColor, 'borderColor is not black'); test.ok('0px', style.borderTopWidth, 'borderTopWidth is not 0px'); test.ok('solid', style.borderLeftStyle, 'borderLeftStyle is not solid'); test.ok('black', style.borderBottomColor, 'borderBottomColor is not black'); style.font = '12em monospace'; test.ok('12em', style.fontSize, 'fontSize is not 12em'); test.ok('monospace', style.fontFamily, 'fontFamily is not monospace'); test.done(); }, 'Test width and height Properties and null and empty strings': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(7); style.height = 6; test.ok('' === style.height, 'height does not remain unset'); style.width = 0; test.ok('0px' === style.width, 'width is not 0px'); style.height = '34%'; test.ok('34%' === style.height, 'height is not 34%'); style.height = ''; test.ok(style.length === 1, 'length is not 1'); test.ok('width: 0px;' === style.cssText, 'cssText is not "width: 0px;"'); style.width = null; test.ok(style.length === 0, 'length is not 0'); test.ok('' === style.cssText, 'cssText is not empty string'); test.done(); }, 'Test Implicit Properties': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(7); style.borderWidth = 0; test.ok(1 === style.length, 'length is not 1'); test.ok('0px' === style.borderWidth, 'borderWidth is not 0px'); test.ok('0px' === style.borderTopWidth, 'borderTopWidth is not 0px'); test.ok('0px' === style.borderBottomWidth, 'borderBottomWidth is not 0px'); test.ok('0px' === style.borderLeftWidth, 'borderLeftWidth is not 0px'); test.ok('0px' === style.borderRightWidth, 'borderRightWidth is not 0px'); test.ok('border-width: 0px;' === style.cssText, 'cssText is not "border-width: 0px", "' + style.cssText + '"'); test.done(); }, 'Test Top, Left, Right, Bottom Properties': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(6); style.top = 0; style.left = '0%'; style.right = '5em'; style.bottom = '12pt'; test.ok('0px' === style.top, 'top is not 0px'); test.ok('0%' === style.left, 'left is not 0%'); test.ok('5em' === style.right, 'right is not 5em'); test.ok('12pt' === style.bottom, 'bottom is not 12pt'); test.ok(4 === style.length, 'length is not 4'); test.ok('top: 0px; left: 0%; right: 5em; bottom: 12pt;' === style.cssText, 'text is not "top: 0px; left: 0%; right: 5em; bottom: 12pt;"'); test.done(); }, 'Test Clear and Clip Properties': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(10); style.clear = 'none'; test.ok('none' === style.clear, 'clear is not none'); style.clear = 'lfet'; // intentionally wrong test.ok('none' === style.clear, 'clear is not still none'); style.clear = 'left'; test.ok('left' === style.clear, 'clear is not left'); style.clear = 'right'; test.ok('right' === style.clear, 'clear is not right'); style.clear = 'both'; test.ok('both' === style.clear, 'clear is not both'); style.clip = 'elipse(5px, 10px)'; test.ok('' === style.clip, 'clip should not be set'); test.ok(1 === style.length, 'length is not 1'); style.clip = 'rect(0, 3Em, 2pt, 50%)'; test.ok('rect(0px, 3em, 2pt, 50%)' === style.clip, 'clip is not "rect(0px, 3em, 2pt, 50%)", "' + style.clip + '"'); test.ok(2 === style.length, 'length is not 2'); test.ok('clear: both; clip: rect(0px, 3em, 2pt, 50%);' === style.cssText, 'cssText is not "clear: both; clip: rect(0px, 3em, 2pt, 50%);"'); test.done(); }, 'Test colors': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(4); style.color = 'rgba(0,0,0,0)'; test.ok('rgba(0, 0, 0, 0)' === style.color, 'color is not rgba(0, 0, 0, 0)'); style.color = 'rgba(5%, 10%, 20%, 0.4)'; test.ok('rgba(12, 25, 51, 0.4)' === style.color, 'color is not rgba(12, 25, 51, 0.4)'); style.color = 'rgb(33%, 34%, 33%)'; test.ok('rgb(84, 86, 84)' === style.color, 'color is not rgb(84, 86, 84)'); style.color = 'rgba(300, 200, 100, 1.5)'; test.ok('rgb(255, 200, 100)' === style.color, 'color is not rgb(255, 200, 100) ' + style.color); test.done(); }, 'Test short hand properties with embedded spaces': function (test) { var style = new cssstyle.CSSStyleDeclaration(); test.expect(3); style.background = 'rgb(0, 0, 0) url(/something/somewhere.jpg)'; test.ok('rgb(0, 0, 0)' === style.backgroundColor, 'backgroundColor is not rgb(0, 0, 0): ' + style.backgroundColor); test.ok('url(/something/somewhere.jpg)' === style.backgroundImage, 'backgroundImage is not url(/something/somewhere.jpg): ' + style.backgroundImage); test.ok('background: rgb(0, 0, 0) url(/something/somewhere.jpg);' === style.cssText, 'cssText is not correct: ' + style.cssText); test.done(); } }; CSSStyleDeclaration/node_modules/0000755000175000017500000000000012337414256015515 5ustar wmbwmbCSSStyleDeclaration/node_modules/.turd0000644000175000017500000000000012337414256016462 0ustar wmbwmb