1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 04:10:04 +02:00
This commit is contained in:
s2
2018-05-05 14:29:20 +02:00
parent 62dd054f83
commit d17c4fe70c
1809 changed files with 262593 additions and 219 deletions

1
node_modules/cssstyle/.npmignore generated vendored Normal file
View File

@@ -0,0 +1 @@
node_module

20
node_modules/cssstyle/MIT-LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright (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.

27
node_modules/cssstyle/README.md generated vendored Normal file
View File

@@ -0,0 +1,27 @@
CSSStyleDeclaration
===================
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
> ```

233
node_modules/cssstyle/lib/CSSStyleDeclaration.js generated vendored Normal file
View File

@@ -0,0 +1,233 @@
/*********************************************************************
* 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;
var dashedToCamelCase = require('./parsers').dashedToCamelCase;
/**
* @constructor
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
*/
var CSSStyleDeclaration = function CSSStyleDeclaration(onChangeCallback) {
this._values = {};
this._importants = {};
this._length = 0;
this._onChange = onChangeCallback || function () { return; };
};
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) {
if (!this._values.hasOwnProperty(name)) {
return "";
}
return this._values[name].toString();
},
/**
*
* @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;
}
var camel_case = dashedToCamelCase(name);
this[camel_case] = value;
this._importants[name] = priority;
},
_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;
this._onChange(this.cssText);
},
/**
*
* @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 prevValue = this._values[name];
delete this._values[name];
delete this._importants[name];
var index = Array.prototype.indexOf.call(this, name);
if (index < 0) {
return prevValue;
}
// That's what WebKit and Opera do
Array.prototype.splice.call(this, index, 1);
// That's what Firefox does
//this[index] = ""
this._onChange(this.cssText);
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;
try {
dummyRule = CSSOM.parse('#bogus{' + value + '}').cssRules[0].style;
} catch (err) {
// malformed css, just return
return;
}
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));
}
this._onChange(this.cssText);
},
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
},
'float': {
get: function () { return this.cssFloat; },
set: function (value) {
this.cssFloat = value;
},
enumerable: true,
configurable: true
}
});
require('./properties')(CSSStyleDeclaration.prototype);
exports.CSSStyleDeclaration = CSSStyleDeclaration;

670
node_modules/cssstyle/lib/parsers.js generated vendored Normal file
View File

@@ -0,0 +1,670 @@
/*********************************************************************
* 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 && type !== exports.TYPES.INTEGER) {
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[0] === '"' || str[0] === "'") && str[0] !== str[str.length - 1]) {
return undefined;
}
if (str[0] === '"' || str[0] === "'") {
str = str.substr(1, str.length - 2);
}
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;
};
exports.dashedToCamelCase = dashedToCamelCase;
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) {
if (current_part !== '') {
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 obj = {};
var type = exports.valueType(v);
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
Object.keys(shorthand_for).forEach(function (property) {
obj[property] = '';
});
return obj;
}
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;
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;
}
//console.log('shorthandSetter for:', property, 'obj:', obj);
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);
// don't add in empty properties
if (obj[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);
// in case the value is something like 'none' that removes all values,
// check that the generated one is not empty, first remove the property
// if it already exists, then call the shorthandGetter, if it's an empty
// string, don't set the property
this.removeProperty(property);
var calculated = exports.shorthandGetter(property, shorthand_for).call(this);
if (calculated !== '') {
this._setProperty(property, calculated);
}
};
};
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;
}
var part_names = ["top","right","bottom","left"];
return function (v) {
if (typeof v === 'number') {
v = v.toString();
}
if (typeof v !== 'string') {
return undefined;
}
var parts;
if (v.toLowerCase() === 'inherit' || v === '') {
parts = [v];
} else {
parts = getParts(v);
}
if (parts.length < 1 || parts.length > 4) {
return undefined;
}
if (!parts.every(isValid)) {
return undefined;
}
parts = parts.map(function (part) {
return parser(part);
});
this._setProperty(property_before + property_after, parts.join(' '));
if (parts.length === 1) {
parts[1] = parts[0];
}
if (parts.length === 2) {
parts[2] = parts[0];
}
if (parts.length === 3) {
parts[3] = parts[1];
}
for (var i = 0; i < 4; i++) {
var property = property_before + "-" + part_names[i] + property_after;
this.removeProperty(property);
if (parts[i] !== '') {
this._values[property] = parts[i];
}
}
return v;
};
};
//
// Companion to implicitSetter, but for the individual parts.
// This sets the individual value, and checks to see if all four
// sub-parts are set. If so, it sets the shorthand version and removes
// the individual parts from the cssText.
//
exports.subImplicitSetter = function (prefix, part, isValid, parser) {
var property = prefix + '-' + part;
var subparts = [prefix+"-top", prefix+"-right", prefix+"-bottom", prefix+"-left"];
return function (v) {
if (typeof v === 'number') {
v = v.toString();
}
if (typeof v !== 'string') {
return undefined;
}
if (!isValid(v)) {
return undefined;
}
v = parser(v);
this._setProperty(property,v);
var parts = [];
for (var i = 0; i < 4; i++) {
if (this._values[subparts[i]] == null || this._values[subparts[i]] === '') {
break;
}
parts.push(this._values[subparts[i]]);
}
if (parts.length === 4) {
for (i = 0; i < 4; i++) {
this.removeProperty(subparts[i]);
this._values[subparts[i]] = parts[i];
}
this._setProperty(prefix,parts.join(" "));
}
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;
};

5858
node_modules/cssstyle/lib/properties.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('alignment-baseline', v);
},
get: function () {
return this.getPropertyValue('alignment-baseline');
},
enumerable: true,
configurable: true
};

65
node_modules/cssstyle/lib/properties/azimuth.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
'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
};

24
node_modules/cssstyle/lib/properties/background.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'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
};

View File

@@ -0,0 +1,22 @@
'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
};

12
node_modules/cssstyle/lib/properties/backgroundClip.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('background-clip', v);
},
get: function () {
return this.getPropertyValue('background-clip');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,33 @@
'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
};

View File

@@ -0,0 +1,29 @@
'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
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('background-origin', v);
},
get: function () {
return this.getPropertyValue('background-origin');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,56 @@
'use strict';
var parsers = require('../parsers');
var valid_keywords = ['top', 'center', 'bottom', 'left', 'right'];
var parse = function parse(v) {
if (v === '' || v === null) {
return undefined;
}
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
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('background-position-x', v);
},
get: function () {
return this.getPropertyValue('background-position-x');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('background-position-y', v);
},
get: function () {
return this.getPropertyValue('background-position-y');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,25 @@
'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
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('background-repeat-x', v);
},
get: function () {
return this.getPropertyValue('background-repeat-x');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('background-repeat-y', v);
},
get: function () {
return this.getPropertyValue('background-repeat-y');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/backgroundSize.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('background-size', v);
},
get: function () {
return this.getPropertyValue('background-size');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/baselineShift.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('baseline-shift', v);
},
get: function () {
return this.getPropertyValue('baseline-shift');
},
enumerable: true,
configurable: true
};

49
node_modules/cssstyle/lib/properties/border.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
'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')
};
var isValid = function isValid(v) {
return shorthandParser(v, shorthand_for) !== undefined;
};
module.exports.isValid = isValid;
var parser = function (v) {
if (v.toString().toLowerCase() === 'none') {
v = '';
}
if (isValid(v)) {
return v;
}
return undefined;
};
var myShorthandSetter = shorthandSetter('border', shorthand_for);
var myShorthandGetter = shorthandGetter('border', shorthand_for);
module.exports.definition = {
set: function (v) {
if (v.toString().toLowerCase() === 'none') {
v = '';
}
myShorthandSetter.call(this, v);
this.removeProperty('border-top');
this.removeProperty('border-left');
this.removeProperty('border-right');
this.removeProperty('border-bottom');
this._values['border-top'] = this._values.border;
this._values['border-left'] = this._values.border;
this._values['border-right'] = this._values.border;
this._values['border-bottom'] = this._values.border;
},
get: myShorthandGetter,
enumerable: true,
configurable: true
};

23
node_modules/cssstyle/lib/properties/borderBottom.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthandParser = require('../parsers').shorthandParser;
var shorthand_for = {
'border-bottom-width': require('./borderBottomWidth'),
'border-bottom-style': require('./borderBottomStyle'),
'border-bottom-color': require('./borderBottomColor')
};
var isValid = function isValid(v) {
return shorthandParser(v, shorthand_for) !== undefined;
};
module.exports.isValid = isValid;
module.exports.definition = {
set: shorthandSetter('border-bottom', shorthand_for),
get: shorthandGetter('border-bottom', shorthand_for),
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,16 @@
'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
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-bottom-left-radius', v);
},
get: function () {
return this.getPropertyValue('border-bottom-left-radius');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-bottom-right-radius', v);
},
get: function () {
return this.getPropertyValue('border-bottom-right-radius');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,21 @@
'use strict';
var isValid = require('./borderStyle').isValid;
module.exports.isValid = isValid;
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
if (v.toLowerCase() === 'none') {
v = '';
this.removeProperty('border-bottom-width');
}
this._setProperty('border-bottom-style', v);
}
},
get: function () {
return this.getPropertyValue('border-bottom-style');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,16 @@
'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
};

25
node_modules/cssstyle/lib/properties/borderCollapse.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
'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
};

28
node_modules/cssstyle/lib/properties/borderColor.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
'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 === '' || 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
};

12
node_modules/cssstyle/lib/properties/borderImage.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-image', v);
},
get: function () {
return this.getPropertyValue('border-image');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-image-outset', v);
},
get: function () {
return this.getPropertyValue('border-image-outset');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-image-repeat', v);
},
get: function () {
return this.getPropertyValue('border-image-repeat');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-image-slice', v);
},
get: function () {
return this.getPropertyValue('border-image-slice');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-image-source', v);
},
get: function () {
return this.getPropertyValue('border-image-source');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-image-width', v);
},
get: function () {
return this.getPropertyValue('border-image-width');
},
enumerable: true,
configurable: true
};

23
node_modules/cssstyle/lib/properties/borderLeft.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthandParser = require('../parsers').shorthandParser;
var shorthand_for = {
'border-left-width': require('./borderLeftWidth'),
'border-left-style': require('./borderLeftStyle'),
'border-left-color': require('./borderLeftColor')
};
var isValid = function isValid(v) {
return shorthandParser(v, shorthand_for) !== undefined;
};
module.exports.isValid = isValid;
module.exports.definition = {
set: shorthandSetter('border-left', shorthand_for),
get: shorthandGetter('border-left', shorthand_for),
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,16 @@
'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
};

View File

@@ -0,0 +1,21 @@
'use strict';
var isValid = require('./borderStyle').isValid;
module.exports.isValid = isValid;
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
if (v.toLowerCase() === 'none') {
v = '';
this.removeProperty('border-left-width');
}
this._setProperty('border-left-style', v);
}
},
get: function () {
return this.getPropertyValue('border-left-style');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,16 @@
'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
};

12
node_modules/cssstyle/lib/properties/borderRadius.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-radius', v);
},
get: function () {
return this.getPropertyValue('border-radius');
},
enumerable: true,
configurable: true
};

23
node_modules/cssstyle/lib/properties/borderRight.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthandParser = require('../parsers').shorthandParser;
var shorthand_for = {
'border-right-width': require('./borderRightWidth'),
'border-right-style': require('./borderRightStyle'),
'border-right-color': require('./borderRightColor')
};
var isValid = function isValid(v) {
return shorthandParser(v, shorthand_for) !== undefined;
};
module.exports.isValid = isValid;
module.exports.definition = {
set: shorthandSetter('border-right', shorthand_for),
get: shorthandGetter('border-right', shorthand_for),
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,16 @@
'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
};

View File

@@ -0,0 +1,21 @@
'use strict';
var isValid = require('./borderStyle').isValid;
module.exports.isValid = isValid;
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
if (v.toLowerCase() === 'none') {
v = '';
this.removeProperty('border-right-width');
}
this._setProperty('border-right-style', v);
}
},
get: function () {
return this.getPropertyValue('border-right-style');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,16 @@
'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
};

42
node_modules/cssstyle/lib/properties/borderSpacing.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
'use strict';
var parsers = require('../parsers');
// <length> <length>? | 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 === '' || v === null) {
return undefined;
}
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
};

27
node_modules/cssstyle/lib/properties/borderStyle.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
'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' && (v === '' || 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
};

22
node_modules/cssstyle/lib/properties/borderTop.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
'use strict';
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthandParser = require('../parsers').shorthandParser;
var shorthand_for = {
'border-top-width': require('./borderTopWidth'),
'border-top-style': require('./borderTopStyle'),
'border-top-color': require('./borderTopColor')
};
module.exports.isValid = function (v) {
return shorthandParser(v, shorthand_for) !== undefined;
};
module.exports.definition = {
set: shorthandSetter('border-top', shorthand_for),
get: shorthandGetter('border-top', shorthand_for),
enumerable: true,
configurable: true
};

16
node_modules/cssstyle/lib/properties/borderTopColor.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'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
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-top-left-radius', v);
},
get: function () {
return this.getPropertyValue('border-top-left-radius');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('border-top-right-radius', v);
},
get: function () {
return this.getPropertyValue('border-top-right-radius');
},
enumerable: true,
configurable: true
};

21
node_modules/cssstyle/lib/properties/borderTopStyle.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
var isValid = require('./borderStyle').isValid;
module.exports.isValid = isValid;
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
if (v.toLowerCase() === 'none') {
v = '';
this.removeProperty('border-top-width');
}
this._setProperty('border-top-style', v);
}
},
get: function () {
return this.getPropertyValue('border-top-style');
},
enumerable: true,
configurable: true
};

17
node_modules/cssstyle/lib/properties/borderTopWidth.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
'use strict';
var isValid = require('./borderWidth').isValid;
module.exports.isValid = 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
};

47
node_modules/cssstyle/lib/properties/borderWidth.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
'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;
}
if (v === '') {
return true;
}
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
};

14
node_modules/cssstyle/lib/properties/bottom.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
'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
};

12
node_modules/cssstyle/lib/properties/boxShadow.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('box-shadow', v);
},
get: function () {
return this.getPropertyValue('box-shadow');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/boxSizing.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('box-sizing', v);
},
get: function () {
return this.getPropertyValue('box-sizing');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/captionSide.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('caption-side', v);
},
get: function () {
return this.getPropertyValue('caption-side');
},
enumerable: true,
configurable: true
};

16
node_modules/cssstyle/lib/properties/clear.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'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
};

49
node_modules/cssstyle/lib/properties/clip.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
'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
};

14
node_modules/cssstyle/lib/properties/color.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
'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
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('color-interpolation', v);
},
get: function () {
return this.getPropertyValue('color-interpolation');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('color-interpolation-filters', v);
},
get: function () {
return this.getPropertyValue('color-interpolation-filters');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/colorProfile.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('color-profile', v);
},
get: function () {
return this.getPropertyValue('color-profile');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/colorRendering.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('color-rendering', v);
},
get: function () {
return this.getPropertyValue('color-rendering');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/content.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('content', v);
},
get: function () {
return this.getPropertyValue('content');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('counter-increment', v);
},
get: function () {
return this.getPropertyValue('counter-increment');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/counterReset.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('counter-reset', v);
},
get: function () {
return this.getPropertyValue('counter-reset');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/cssFloat.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('float', v);
},
get: function () {
return this.getPropertyValue('float');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/cue.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('cue', v);
},
get: function () {
return this.getPropertyValue('cue');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/cueAfter.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('cue-after', v);
},
get: function () {
return this.getPropertyValue('cue-after');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/cueBefore.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('cue-before', v);
},
get: function () {
return this.getPropertyValue('cue-before');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/cursor.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('cursor', v);
},
get: function () {
return this.getPropertyValue('cursor');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/direction.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('direction', v);
},
get: function () {
return this.getPropertyValue('direction');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/display.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('display', v);
},
get: function () {
return this.getPropertyValue('display');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('dominant-baseline', v);
},
get: function () {
return this.getPropertyValue('dominant-baseline');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/elevation.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('elevation', v);
},
get: function () {
return this.getPropertyValue('elevation');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/emptyCells.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('empty-cells', v);
},
get: function () {
return this.getPropertyValue('empty-cells');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('enable-background', v);
},
get: function () {
return this.getPropertyValue('enable-background');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/fill.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('fill', v);
},
get: function () {
return this.getPropertyValue('fill');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/fillOpacity.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('fill-opacity', v);
},
get: function () {
return this.getPropertyValue('fill-opacity');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/fillRule.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('fill-rule', v);
},
get: function () {
return this.getPropertyValue('fill-rule');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/filter.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('filter', v);
},
get: function () {
return this.getPropertyValue('filter');
},
enumerable: true,
configurable: true
};

14
node_modules/cssstyle/lib/properties/floodColor.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
'use strict';
var parseColor = require('../parsers').parseColor;
module.exports.definition = {
set: function (v) {
this._setProperty('flood-color', parseColor(v));
},
get: function () {
return this.getPropertyValue('flood-color');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/floodOpacity.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('flood-opacity', v);
},
get: function () {
return this.getPropertyValue('flood-opacity');
},
enumerable: true,
configurable: true
};

40
node_modules/cssstyle/lib/properties/font.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
'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('font', 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('font', shorthand_for),
enumerable: true,
configurable: true
};

33
node_modules/cssstyle/lib/properties/fontFamily.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
var TYPES = require('../parsers').TYPES;
var valueType = require('../parsers').valueType;
var partsRegEx = /\s*,\s*/;
module.exports.isValid = function isValid(v) {
if (v === '' || v === null) {
return true;
}
var parts = v.split(partsRegEx);
var len = parts.length;
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
};

25
node_modules/cssstyle/lib/properties/fontSize.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
'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
};

12
node_modules/cssstyle/lib/properties/fontSizeAdjust.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'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
};

12
node_modules/cssstyle/lib/properties/fontStretch.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('font-stretch', v);
},
get: function () {
return this.getPropertyValue('font-stretch');
},
enumerable: true,
configurable: true
};

18
node_modules/cssstyle/lib/properties/fontStyle.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'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
};

18
node_modules/cssstyle/lib/properties/fontVariant.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'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
};

18
node_modules/cssstyle/lib/properties/fontWeight.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'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
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('glyph-orientation-horizontal', v);
},
get: function () {
return this.getPropertyValue('glyph-orientation-horizontal');
},
enumerable: true,
configurable: true
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('glyph-orientation-vertical', v);
},
get: function () {
return this.getPropertyValue('glyph-orientation-vertical');
},
enumerable: true,
configurable: true
};

24
node_modules/cssstyle/lib/properties/height.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'use strict';
var parseMeasurement = require('../parsers').parseMeasurement;
function parse(v) {
if (String(v).toLowerCase() === 'auto') {
return 'auto';
}
if (String(v).toLowerCase() === 'inherit') {
return 'inherit';
}
return parseMeasurement(v);
}
module.exports.definition = {
set: function (v) {
this._setProperty('height', parse(v));
},
get: function () {
return this.getPropertyValue('height');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/imageRendering.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('image-rendering', v);
},
get: function () {
return this.getPropertyValue('image-rendering');
},
enumerable: true,
configurable: true
};

12
node_modules/cssstyle/lib/properties/kerning.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
module.exports.definition = {
set: function (v) {
this._setProperty('kerning', v);
},
get: function () {
return this.getPropertyValue('kerning');
},
enumerable: true,
configurable: true
};

14
node_modules/cssstyle/lib/properties/left.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
'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
};

Some files were not shown because too many files have changed in this diff Show More