This commit is contained in:
Stephen Franceschelli 2019-07-30 13:41:05 -04:00
parent 596a6da241
commit c1a589c5b6
7078 changed files with 1882834 additions and 319 deletions

3
node_modules/cssstyle/.eslintignore generated vendored Normal file
View file

@ -0,0 +1,3 @@
node_modules
lib/implementedProperties.js
lib/properties.js

50
node_modules/cssstyle/.eslintrc.js generated vendored Normal file
View file

@ -0,0 +1,50 @@
'use strict';
module.exports = {
root: true,
extends: ['eslint:recommended', 'prettier'],
parserOptions: {
ecmaVersion: 2018,
},
env: {
es6: true,
},
globals: {
exports: true,
module: true,
require: true,
window: true,
},
plugins: ['prettier'],
rules: {
'prettier/prettier': [
'warn',
{
printWidth: 100,
singleQuote: true,
trailingComma: 'es5',
},
],
strict: ['warn', 'global'],
},
overrides: [
{
files: ['lib/implementedProperties.js', 'lib/properties.js'],
rules: {
'prettier/prettier': 'off',
},
},
{
files: 'scripts/**/*',
rules: {
'no-console': 'off',
},
},
{
files: ['scripts/**/*', 'tests/**/*'],
env: {
node: true,
},
},
],
};

15
node_modules/cssstyle/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,15 @@
sudo: false
language: node_js
cache:
directories:
- node_modules
notifications:
email: true
node_js:
- 6
- 8
- 10
- 11
script:
- npm run test-ci

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
[![NpmVersion](https://img.shields.io/npm/v/cssstyle.svg)](https://www.npmjs.com/package/cssstyle) [![Build Status](https://travis-ci.org/jsakas/CSSStyleDeclaration.svg?branch=master)](https://travis-ci.org/jsakas/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 resistance 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
```

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

@ -0,0 +1,255 @@
/*********************************************************************
* This is a fork from the CSS Style Declaration part of
* https://github.com/NV/CSSOM
********************************************************************/
'use strict';
var CSSOM = require('cssom');
var allProperties = require('./allProperties');
var allExtraProperties = require('./allExtraProperties');
var implementedProperties = require('./implementedProperties');
var { dashedToCamelCase } = require('./parsers');
var getBasicPropertyDescriptor = require('./utils/getBasicPropertyDescriptor');
/**
* @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 lowercaseName = name.toLowerCase();
if (!allProperties.has(lowercaseName) && !allExtraProperties.has(lowercaseName)) {
return;
}
this[lowercaseName] = value;
this._importants[lowercaseName] = 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,
},
});
require('./properties')(CSSStyleDeclaration.prototype);
allProperties.forEach(function(property) {
if (!implementedProperties.has(property)) {
var declaration = getBasicPropertyDescriptor(property);
Object.defineProperty(CSSStyleDeclaration.prototype, property, declaration);
Object.defineProperty(CSSStyleDeclaration.prototype, dashedToCamelCase(property), declaration);
}
});
allExtraProperties.forEach(function(property) {
if (!implementedProperties.has(property)) {
var declaration = getBasicPropertyDescriptor(property);
Object.defineProperty(CSSStyleDeclaration.prototype, property, declaration);
Object.defineProperty(CSSStyleDeclaration.prototype, dashedToCamelCase(property), declaration);
}
});
exports.CSSStyleDeclaration = CSSStyleDeclaration;

248
node_modules/cssstyle/lib/allExtraProperties.js generated vendored Normal file
View file

@ -0,0 +1,248 @@
'use strict';
/**
* This file contains all implemented properties that are not a part of any
* current specifications or drafts, but are handled by browsers nevertheless.
*/
var allExtraProperties = new Set();
module.exports = allExtraProperties;
allExtraProperties.add('background-position-x');
allExtraProperties.add('background-position-y');
allExtraProperties.add('background-repeat-x');
allExtraProperties.add('background-repeat-y');
allExtraProperties.add('color-interpolation');
allExtraProperties.add('color-profile');
allExtraProperties.add('color-rendering');
allExtraProperties.add('css-float');
allExtraProperties.add('enable-background');
allExtraProperties.add('fill');
allExtraProperties.add('fill-opacity');
allExtraProperties.add('fill-rule');
allExtraProperties.add('glyph-orientation-horizontal');
allExtraProperties.add('image-rendering');
allExtraProperties.add('kerning');
allExtraProperties.add('marker');
allExtraProperties.add('marker-end');
allExtraProperties.add('marker-mid');
allExtraProperties.add('marker-offset');
allExtraProperties.add('marker-start');
allExtraProperties.add('marks');
allExtraProperties.add('pointer-events');
allExtraProperties.add('shape-rendering');
allExtraProperties.add('size');
allExtraProperties.add('src');
allExtraProperties.add('stop-color');
allExtraProperties.add('stop-opacity');
allExtraProperties.add('stroke');
allExtraProperties.add('stroke-dasharray');
allExtraProperties.add('stroke-dashoffset');
allExtraProperties.add('stroke-linecap');
allExtraProperties.add('stroke-linejoin');
allExtraProperties.add('stroke-miterlimit');
allExtraProperties.add('stroke-opacity');
allExtraProperties.add('stroke-width');
allExtraProperties.add('text-anchor');
allExtraProperties.add('text-line-through');
allExtraProperties.add('text-line-through-color');
allExtraProperties.add('text-line-through-mode');
allExtraProperties.add('text-line-through-style');
allExtraProperties.add('text-line-through-width');
allExtraProperties.add('text-overline');
allExtraProperties.add('text-overline-color');
allExtraProperties.add('text-overline-mode');
allExtraProperties.add('text-overline-style');
allExtraProperties.add('text-overline-width');
allExtraProperties.add('text-rendering');
allExtraProperties.add('text-underline');
allExtraProperties.add('text-underline-color');
allExtraProperties.add('text-underline-mode');
allExtraProperties.add('text-underline-style');
allExtraProperties.add('text-underline-width');
allExtraProperties.add('unicode-range');
allExtraProperties.add('vector-effect');
allExtraProperties.add('webkit-animation');
allExtraProperties.add('webkit-animation-delay');
allExtraProperties.add('webkit-animation-direction');
allExtraProperties.add('webkit-animation-duration');
allExtraProperties.add('webkit-animation-fill-mode');
allExtraProperties.add('webkit-animation-iteration-count');
allExtraProperties.add('webkit-animation-name');
allExtraProperties.add('webkit-animation-play-state');
allExtraProperties.add('webkit-animation-timing-function');
allExtraProperties.add('webkit-appearance');
allExtraProperties.add('webkit-aspect-ratio');
allExtraProperties.add('webkit-backface-visibility');
allExtraProperties.add('webkit-background-clip');
allExtraProperties.add('webkit-background-composite');
allExtraProperties.add('webkit-background-origin');
allExtraProperties.add('webkit-background-size');
allExtraProperties.add('webkit-border-after');
allExtraProperties.add('webkit-border-after-color');
allExtraProperties.add('webkit-border-after-style');
allExtraProperties.add('webkit-border-after-width');
allExtraProperties.add('webkit-border-before');
allExtraProperties.add('webkit-border-before-color');
allExtraProperties.add('webkit-border-before-style');
allExtraProperties.add('webkit-border-before-width');
allExtraProperties.add('webkit-border-end');
allExtraProperties.add('webkit-border-end-color');
allExtraProperties.add('webkit-border-end-style');
allExtraProperties.add('webkit-border-end-width');
allExtraProperties.add('webkit-border-fit');
allExtraProperties.add('webkit-border-horizontal-spacing');
allExtraProperties.add('webkit-border-image');
allExtraProperties.add('webkit-border-radius');
allExtraProperties.add('webkit-border-start');
allExtraProperties.add('webkit-border-start-color');
allExtraProperties.add('webkit-border-start-style');
allExtraProperties.add('webkit-border-start-width');
allExtraProperties.add('webkit-border-vertical-spacing');
allExtraProperties.add('webkit-box-align');
allExtraProperties.add('webkit-box-direction');
allExtraProperties.add('webkit-box-flex');
allExtraProperties.add('webkit-box-flex-group');
allExtraProperties.add('webkit-box-lines');
allExtraProperties.add('webkit-box-ordinal-group');
allExtraProperties.add('webkit-box-orient');
allExtraProperties.add('webkit-box-pack');
allExtraProperties.add('webkit-box-reflect');
allExtraProperties.add('webkit-box-shadow');
allExtraProperties.add('webkit-color-correction');
allExtraProperties.add('webkit-column-axis');
allExtraProperties.add('webkit-column-break-after');
allExtraProperties.add('webkit-column-break-before');
allExtraProperties.add('webkit-column-break-inside');
allExtraProperties.add('webkit-column-count');
allExtraProperties.add('webkit-column-gap');
allExtraProperties.add('webkit-column-rule');
allExtraProperties.add('webkit-column-rule-color');
allExtraProperties.add('webkit-column-rule-style');
allExtraProperties.add('webkit-column-rule-width');
allExtraProperties.add('webkit-columns');
allExtraProperties.add('webkit-column-span');
allExtraProperties.add('webkit-column-width');
allExtraProperties.add('webkit-filter');
allExtraProperties.add('webkit-flex-align');
allExtraProperties.add('webkit-flex-direction');
allExtraProperties.add('webkit-flex-flow');
allExtraProperties.add('webkit-flex-item-align');
allExtraProperties.add('webkit-flex-line-pack');
allExtraProperties.add('webkit-flex-order');
allExtraProperties.add('webkit-flex-pack');
allExtraProperties.add('webkit-flex-wrap');
allExtraProperties.add('webkit-flow-from');
allExtraProperties.add('webkit-flow-into');
allExtraProperties.add('webkit-font-feature-settings');
allExtraProperties.add('webkit-font-kerning');
allExtraProperties.add('webkit-font-size-delta');
allExtraProperties.add('webkit-font-smoothing');
allExtraProperties.add('webkit-font-variant-ligatures');
allExtraProperties.add('webkit-highlight');
allExtraProperties.add('webkit-hyphenate-character');
allExtraProperties.add('webkit-hyphenate-limit-after');
allExtraProperties.add('webkit-hyphenate-limit-before');
allExtraProperties.add('webkit-hyphenate-limit-lines');
allExtraProperties.add('webkit-hyphens');
allExtraProperties.add('webkit-line-align');
allExtraProperties.add('webkit-line-box-contain');
allExtraProperties.add('webkit-line-break');
allExtraProperties.add('webkit-line-clamp');
allExtraProperties.add('webkit-line-grid');
allExtraProperties.add('webkit-line-snap');
allExtraProperties.add('webkit-locale');
allExtraProperties.add('webkit-logical-height');
allExtraProperties.add('webkit-logical-width');
allExtraProperties.add('webkit-margin-after');
allExtraProperties.add('webkit-margin-after-collapse');
allExtraProperties.add('webkit-margin-before');
allExtraProperties.add('webkit-margin-before-collapse');
allExtraProperties.add('webkit-margin-bottom-collapse');
allExtraProperties.add('webkit-margin-collapse');
allExtraProperties.add('webkit-margin-end');
allExtraProperties.add('webkit-margin-start');
allExtraProperties.add('webkit-margin-top-collapse');
allExtraProperties.add('webkit-marquee');
allExtraProperties.add('webkit-marquee-direction');
allExtraProperties.add('webkit-marquee-increment');
allExtraProperties.add('webkit-marquee-repetition');
allExtraProperties.add('webkit-marquee-speed');
allExtraProperties.add('webkit-marquee-style');
allExtraProperties.add('webkit-mask');
allExtraProperties.add('webkit-mask-attachment');
allExtraProperties.add('webkit-mask-box-image');
allExtraProperties.add('webkit-mask-box-image-outset');
allExtraProperties.add('webkit-mask-box-image-repeat');
allExtraProperties.add('webkit-mask-box-image-slice');
allExtraProperties.add('webkit-mask-box-image-source');
allExtraProperties.add('webkit-mask-box-image-width');
allExtraProperties.add('webkit-mask-clip');
allExtraProperties.add('webkit-mask-composite');
allExtraProperties.add('webkit-mask-image');
allExtraProperties.add('webkit-mask-origin');
allExtraProperties.add('webkit-mask-position');
allExtraProperties.add('webkit-mask-position-x');
allExtraProperties.add('webkit-mask-position-y');
allExtraProperties.add('webkit-mask-repeat');
allExtraProperties.add('webkit-mask-repeat-x');
allExtraProperties.add('webkit-mask-repeat-y');
allExtraProperties.add('webkit-mask-size');
allExtraProperties.add('webkit-match-nearest-mail-blockquote-color');
allExtraProperties.add('webkit-max-logical-height');
allExtraProperties.add('webkit-max-logical-width');
allExtraProperties.add('webkit-min-logical-height');
allExtraProperties.add('webkit-min-logical-width');
allExtraProperties.add('webkit-nbsp-mode');
allExtraProperties.add('webkit-overflow-scrolling');
allExtraProperties.add('webkit-padding-after');
allExtraProperties.add('webkit-padding-before');
allExtraProperties.add('webkit-padding-end');
allExtraProperties.add('webkit-padding-start');
allExtraProperties.add('webkit-perspective');
allExtraProperties.add('webkit-perspective-origin');
allExtraProperties.add('webkit-perspective-origin-x');
allExtraProperties.add('webkit-perspective-origin-y');
allExtraProperties.add('webkit-print-color-adjust');
allExtraProperties.add('webkit-region-break-after');
allExtraProperties.add('webkit-region-break-before');
allExtraProperties.add('webkit-region-break-inside');
allExtraProperties.add('webkit-region-overflow');
allExtraProperties.add('webkit-rtl-ordering');
allExtraProperties.add('webkit-svg-shadow');
allExtraProperties.add('webkit-tap-highlight-color');
allExtraProperties.add('webkit-text-combine');
allExtraProperties.add('webkit-text-decorations-in-effect');
allExtraProperties.add('webkit-text-emphasis');
allExtraProperties.add('webkit-text-emphasis-color');
allExtraProperties.add('webkit-text-emphasis-position');
allExtraProperties.add('webkit-text-emphasis-style');
allExtraProperties.add('webkit-text-fill-color');
allExtraProperties.add('webkit-text-orientation');
allExtraProperties.add('webkit-text-security');
allExtraProperties.add('webkit-text-size-adjust');
allExtraProperties.add('webkit-text-stroke');
allExtraProperties.add('webkit-text-stroke-color');
allExtraProperties.add('webkit-text-stroke-width');
allExtraProperties.add('webkit-transform');
allExtraProperties.add('webkit-transform-origin');
allExtraProperties.add('webkit-transform-origin-x');
allExtraProperties.add('webkit-transform-origin-y');
allExtraProperties.add('webkit-transform-origin-z');
allExtraProperties.add('webkit-transform-style');
allExtraProperties.add('webkit-transition');
allExtraProperties.add('webkit-transition-delay');
allExtraProperties.add('webkit-transition-duration');
allExtraProperties.add('webkit-transition-property');
allExtraProperties.add('webkit-transition-timing-function');
allExtraProperties.add('webkit-user-drag');
allExtraProperties.add('webkit-user-modify');
allExtraProperties.add('webkit-user-select');
allExtraProperties.add('webkit-wrap');
allExtraProperties.add('webkit-wrap-flow');
allExtraProperties.add('webkit-wrap-margin');
allExtraProperties.add('webkit-wrap-padding');
allExtraProperties.add('webkit-wrap-shape-inside');
allExtraProperties.add('webkit-wrap-shape-outside');
allExtraProperties.add('webkit-wrap-through');
allExtraProperties.add('webkit-writing-mode');
allExtraProperties.add('zoom');

457
node_modules/cssstyle/lib/allProperties.js generated vendored Normal file
View file

@ -0,0 +1,457 @@
'use strict';
// autogenerated - 2/3/2019
/*
*
* https://www.w3.org/Style/CSS/all-properties.en.html
*/
var allProperties = new Set();
module.exports = allProperties;
allProperties.add('align-content');
allProperties.add('align-items');
allProperties.add('align-self');
allProperties.add('alignment-baseline');
allProperties.add('all');
allProperties.add('animation');
allProperties.add('animation-delay');
allProperties.add('animation-direction');
allProperties.add('animation-duration');
allProperties.add('animation-fill-mode');
allProperties.add('animation-iteration-count');
allProperties.add('animation-name');
allProperties.add('animation-play-state');
allProperties.add('animation-timing-function');
allProperties.add('appearance');
allProperties.add('azimuth');
allProperties.add('background');
allProperties.add('background-attachment');
allProperties.add('background-blend-mode');
allProperties.add('background-clip');
allProperties.add('background-color');
allProperties.add('background-image');
allProperties.add('background-origin');
allProperties.add('background-position');
allProperties.add('background-repeat');
allProperties.add('background-size');
allProperties.add('baseline-shift');
allProperties.add('block-overflow');
allProperties.add('block-size');
allProperties.add('bookmark-label');
allProperties.add('bookmark-level');
allProperties.add('bookmark-state');
allProperties.add('border');
allProperties.add('border-block');
allProperties.add('border-block-color');
allProperties.add('border-block-end');
allProperties.add('border-block-end-color');
allProperties.add('border-block-end-style');
allProperties.add('border-block-end-width');
allProperties.add('border-block-start');
allProperties.add('border-block-start-color');
allProperties.add('border-block-start-style');
allProperties.add('border-block-start-width');
allProperties.add('border-block-style');
allProperties.add('border-block-width');
allProperties.add('border-bottom');
allProperties.add('border-bottom-color');
allProperties.add('border-bottom-left-radius');
allProperties.add('border-bottom-right-radius');
allProperties.add('border-bottom-style');
allProperties.add('border-bottom-width');
allProperties.add('border-boundary');
allProperties.add('border-collapse');
allProperties.add('border-color');
allProperties.add('border-end-end-radius');
allProperties.add('border-end-start-radius');
allProperties.add('border-image');
allProperties.add('border-image-outset');
allProperties.add('border-image-repeat');
allProperties.add('border-image-slice');
allProperties.add('border-image-source');
allProperties.add('border-image-width');
allProperties.add('border-inline');
allProperties.add('border-inline-color');
allProperties.add('border-inline-end');
allProperties.add('border-inline-end-color');
allProperties.add('border-inline-end-style');
allProperties.add('border-inline-end-width');
allProperties.add('border-inline-start');
allProperties.add('border-inline-start-color');
allProperties.add('border-inline-start-style');
allProperties.add('border-inline-start-width');
allProperties.add('border-inline-style');
allProperties.add('border-inline-width');
allProperties.add('border-left');
allProperties.add('border-left-color');
allProperties.add('border-left-style');
allProperties.add('border-left-width');
allProperties.add('border-radius');
allProperties.add('border-right');
allProperties.add('border-right-color');
allProperties.add('border-right-style');
allProperties.add('border-right-width');
allProperties.add('border-spacing');
allProperties.add('border-start-end-radius');
allProperties.add('border-start-start-radius');
allProperties.add('border-style');
allProperties.add('border-top');
allProperties.add('border-top-color');
allProperties.add('border-top-left-radius');
allProperties.add('border-top-right-radius');
allProperties.add('border-top-style');
allProperties.add('border-top-width');
allProperties.add('border-width');
allProperties.add('bottom');
allProperties.add('box-decoration-break');
allProperties.add('box-shadow');
allProperties.add('box-sizing');
allProperties.add('box-snap');
allProperties.add('break-after');
allProperties.add('break-before');
allProperties.add('break-inside');
allProperties.add('caption-side');
allProperties.add('caret');
allProperties.add('caret-color');
allProperties.add('caret-shape');
allProperties.add('chains');
allProperties.add('clear');
allProperties.add('clip');
allProperties.add('clip-path');
allProperties.add('clip-rule');
allProperties.add('color');
allProperties.add('color-interpolation-filters');
allProperties.add('column-count');
allProperties.add('column-fill');
allProperties.add('column-gap');
allProperties.add('column-rule');
allProperties.add('column-rule-color');
allProperties.add('column-rule-style');
allProperties.add('column-rule-width');
allProperties.add('column-span');
allProperties.add('column-width');
allProperties.add('columns');
allProperties.add('contain');
allProperties.add('content');
allProperties.add('continue');
allProperties.add('counter-increment');
allProperties.add('counter-reset');
allProperties.add('counter-set');
allProperties.add('cue');
allProperties.add('cue-after');
allProperties.add('cue-before');
allProperties.add('cursor');
allProperties.add('direction');
allProperties.add('display');
allProperties.add('dominant-baseline');
allProperties.add('elevation');
allProperties.add('empty-cells');
allProperties.add('filter');
allProperties.add('flex');
allProperties.add('flex-basis');
allProperties.add('flex-direction');
allProperties.add('flex-flow');
allProperties.add('flex-grow');
allProperties.add('flex-shrink');
allProperties.add('flex-wrap');
allProperties.add('float');
allProperties.add('flood-color');
allProperties.add('flood-opacity');
allProperties.add('flow');
allProperties.add('flow-from');
allProperties.add('flow-into');
allProperties.add('font');
allProperties.add('font-family');
allProperties.add('font-feature-settings');
allProperties.add('font-kerning');
allProperties.add('font-language-override');
allProperties.add('font-max-size');
allProperties.add('font-min-size');
allProperties.add('font-optical-sizing');
allProperties.add('font-palette');
allProperties.add('font-size');
allProperties.add('font-size-adjust');
allProperties.add('font-stretch');
allProperties.add('font-style');
allProperties.add('font-synthesis');
allProperties.add('font-synthesis-small-caps');
allProperties.add('font-synthesis-style');
allProperties.add('font-synthesis-weight');
allProperties.add('font-variant');
allProperties.add('font-variant-alternates');
allProperties.add('font-variant-caps');
allProperties.add('font-variant-east-asian');
allProperties.add('font-variant-emoji');
allProperties.add('font-variant-ligatures');
allProperties.add('font-variant-numeric');
allProperties.add('font-variant-position');
allProperties.add('font-variation-settings');
allProperties.add('font-weight');
allProperties.add('footnote-display');
allProperties.add('footnote-policy');
allProperties.add('gap');
allProperties.add('glyph-orientation-vertical');
allProperties.add('grid');
allProperties.add('grid-area');
allProperties.add('grid-auto-columns');
allProperties.add('grid-auto-flow');
allProperties.add('grid-auto-rows');
allProperties.add('grid-column');
allProperties.add('grid-column-end');
allProperties.add('grid-column-start');
allProperties.add('grid-row');
allProperties.add('grid-row-end');
allProperties.add('grid-row-start');
allProperties.add('grid-template');
allProperties.add('grid-template-areas');
allProperties.add('grid-template-columns');
allProperties.add('grid-template-rows');
allProperties.add('hanging-punctuation');
allProperties.add('height');
allProperties.add('hyphenate-character');
allProperties.add('hyphenate-limit-chars');
allProperties.add('hyphenate-limit-last');
allProperties.add('hyphenate-limit-lines');
allProperties.add('hyphenate-limit-zone');
allProperties.add('hyphens');
allProperties.add('image-orientation');
allProperties.add('image-resolution');
allProperties.add('initial-letters');
allProperties.add('initial-letters-align');
allProperties.add('initial-letters-wrap');
allProperties.add('inline-size');
allProperties.add('inline-sizing');
allProperties.add('inset');
allProperties.add('inset-block');
allProperties.add('inset-block-end');
allProperties.add('inset-block-start');
allProperties.add('inset-inline');
allProperties.add('inset-inline-end');
allProperties.add('inset-inline-start');
allProperties.add('isolation');
allProperties.add('justify-content');
allProperties.add('justify-items');
allProperties.add('justify-self');
allProperties.add('left');
allProperties.add('letter-spacing');
allProperties.add('lighting-color');
allProperties.add('line-break');
allProperties.add('line-clamp');
allProperties.add('line-grid');
allProperties.add('line-height');
allProperties.add('line-padding');
allProperties.add('line-snap');
allProperties.add('list-style');
allProperties.add('list-style-image');
allProperties.add('list-style-position');
allProperties.add('list-style-type');
allProperties.add('margin');
allProperties.add('margin-block');
allProperties.add('margin-block-end');
allProperties.add('margin-block-start');
allProperties.add('margin-bottom');
allProperties.add('margin-inline');
allProperties.add('margin-inline-end');
allProperties.add('margin-inline-start');
allProperties.add('margin-left');
allProperties.add('margin-right');
allProperties.add('margin-top');
allProperties.add('margin-trim');
allProperties.add('marker-side');
allProperties.add('mask');
allProperties.add('mask-border');
allProperties.add('mask-border-mode');
allProperties.add('mask-border-outset');
allProperties.add('mask-border-repeat');
allProperties.add('mask-border-slice');
allProperties.add('mask-border-source');
allProperties.add('mask-border-width');
allProperties.add('mask-clip');
allProperties.add('mask-composite');
allProperties.add('mask-image');
allProperties.add('mask-mode');
allProperties.add('mask-origin');
allProperties.add('mask-position');
allProperties.add('mask-repeat');
allProperties.add('mask-size');
allProperties.add('mask-type');
allProperties.add('max-block-size');
allProperties.add('max-height');
allProperties.add('max-inline-size');
allProperties.add('max-lines');
allProperties.add('max-width');
allProperties.add('min-block-size');
allProperties.add('min-height');
allProperties.add('min-inline-size');
allProperties.add('min-width');
allProperties.add('mix-blend-mode');
allProperties.add('nav-down');
allProperties.add('nav-left');
allProperties.add('nav-right');
allProperties.add('nav-up');
allProperties.add('object-fit');
allProperties.add('object-position');
allProperties.add('offset');
allProperties.add('offset-after');
allProperties.add('offset-anchor');
allProperties.add('offset-before');
allProperties.add('offset-distance');
allProperties.add('offset-end');
allProperties.add('offset-path');
allProperties.add('offset-position');
allProperties.add('offset-rotate');
allProperties.add('offset-start');
allProperties.add('opacity');
allProperties.add('order');
allProperties.add('orphans');
allProperties.add('outline');
allProperties.add('outline-color');
allProperties.add('outline-offset');
allProperties.add('outline-style');
allProperties.add('outline-width');
allProperties.add('overflow');
allProperties.add('overflow-block');
allProperties.add('overflow-inline');
allProperties.add('overflow-wrap');
allProperties.add('overflow-x');
allProperties.add('overflow-y');
allProperties.add('padding');
allProperties.add('padding-block');
allProperties.add('padding-block-end');
allProperties.add('padding-block-start');
allProperties.add('padding-bottom');
allProperties.add('padding-inline');
allProperties.add('padding-inline-end');
allProperties.add('padding-inline-start');
allProperties.add('padding-left');
allProperties.add('padding-right');
allProperties.add('padding-top');
allProperties.add('page');
allProperties.add('page-break-after');
allProperties.add('page-break-before');
allProperties.add('page-break-inside');
allProperties.add('pause');
allProperties.add('pause-after');
allProperties.add('pause-before');
allProperties.add('pitch');
allProperties.add('pitch-range');
allProperties.add('place-content');
allProperties.add('place-items');
allProperties.add('place-self');
allProperties.add('play-during');
allProperties.add('position');
allProperties.add('presentation-level');
allProperties.add('quotes');
allProperties.add('region-fragment');
allProperties.add('resize');
allProperties.add('rest');
allProperties.add('rest-after');
allProperties.add('rest-before');
allProperties.add('richness');
allProperties.add('right');
allProperties.add('row-gap');
allProperties.add('ruby-align');
allProperties.add('ruby-merge');
allProperties.add('ruby-position');
allProperties.add('running');
allProperties.add('scroll-behavior');
allProperties.add('scroll-margin');
allProperties.add('scroll-margin-block');
allProperties.add('scroll-margin-block-end');
allProperties.add('scroll-margin-block-start');
allProperties.add('scroll-margin-bottom');
allProperties.add('scroll-margin-inline');
allProperties.add('scroll-margin-inline-end');
allProperties.add('scroll-margin-inline-start');
allProperties.add('scroll-margin-left');
allProperties.add('scroll-margin-right');
allProperties.add('scroll-margin-top');
allProperties.add('scroll-padding');
allProperties.add('scroll-padding-block');
allProperties.add('scroll-padding-block-end');
allProperties.add('scroll-padding-block-start');
allProperties.add('scroll-padding-bottom');
allProperties.add('scroll-padding-inline');
allProperties.add('scroll-padding-inline-end');
allProperties.add('scroll-padding-inline-start');
allProperties.add('scroll-padding-left');
allProperties.add('scroll-padding-right');
allProperties.add('scroll-padding-top');
allProperties.add('scroll-snap-align');
allProperties.add('scroll-snap-stop');
allProperties.add('scroll-snap-type');
allProperties.add('shape-image-threshold');
allProperties.add('shape-inside');
allProperties.add('shape-margin');
allProperties.add('shape-outside');
allProperties.add('speak');
allProperties.add('speak-as');
allProperties.add('speak-header');
allProperties.add('speak-numeral');
allProperties.add('speak-punctuation');
allProperties.add('speech-rate');
allProperties.add('stress');
allProperties.add('string-set');
allProperties.add('tab-size');
allProperties.add('table-layout');
allProperties.add('text-align');
allProperties.add('text-align-all');
allProperties.add('text-align-last');
allProperties.add('text-combine-upright');
allProperties.add('text-decoration');
allProperties.add('text-decoration-color');
allProperties.add('text-decoration-line');
allProperties.add('text-decoration-style');
allProperties.add('text-emphasis');
allProperties.add('text-emphasis-color');
allProperties.add('text-emphasis-position');
allProperties.add('text-emphasis-style');
allProperties.add('text-group-align');
allProperties.add('text-indent');
allProperties.add('text-justify');
allProperties.add('text-orientation');
allProperties.add('text-overflow');
allProperties.add('text-shadow');
allProperties.add('text-space-collapse');
allProperties.add('text-space-trim');
allProperties.add('text-spacing');
allProperties.add('text-transform');
allProperties.add('text-underline-position');
allProperties.add('text-wrap');
allProperties.add('top');
allProperties.add('transform');
allProperties.add('transform-box');
allProperties.add('transform-origin');
allProperties.add('transition');
allProperties.add('transition-delay');
allProperties.add('transition-duration');
allProperties.add('transition-property');
allProperties.add('transition-timing-function');
allProperties.add('unicode-bidi');
allProperties.add('user-select');
allProperties.add('vertical-align');
allProperties.add('visibility');
allProperties.add('voice-balance');
allProperties.add('voice-duration');
allProperties.add('voice-family');
allProperties.add('voice-pitch');
allProperties.add('voice-range');
allProperties.add('voice-rate');
allProperties.add('voice-stress');
allProperties.add('voice-volume');
allProperties.add('volume');
allProperties.add('white-space');
allProperties.add('widows');
allProperties.add('width');
allProperties.add('will-change');
allProperties.add('word-break');
allProperties.add('word-spacing');
allProperties.add('word-wrap');
allProperties.add('wrap-after');
allProperties.add('wrap-before');
allProperties.add('wrap-flow');
allProperties.add('wrap-inside');
allProperties.add('wrap-through');
allProperties.add('writing-mode');
allProperties.add('z-index');

6
node_modules/cssstyle/lib/constants.js generated vendored Normal file
View file

@ -0,0 +1,6 @@
'use strict';
module.exports.POSITION_AT_SHORTHAND = {
first: 0,
second: 1,
};

90
node_modules/cssstyle/lib/implementedProperties.js generated vendored Normal file
View file

@ -0,0 +1,90 @@
'use strict';
// autogenerated - 7/15/2019
/*
*
* https://www.w3.org/Style/CSS/all-properties.en.html
*/
var implementedProperties = new Set();
implementedProperties.add("azimuth");
implementedProperties.add("background");
implementedProperties.add("background-attachment");
implementedProperties.add("background-color");
implementedProperties.add("background-image");
implementedProperties.add("background-position");
implementedProperties.add("background-repeat");
implementedProperties.add("border");
implementedProperties.add("border-bottom");
implementedProperties.add("border-bottom-color");
implementedProperties.add("border-bottom-style");
implementedProperties.add("border-bottom-width");
implementedProperties.add("border-collapse");
implementedProperties.add("border-color");
implementedProperties.add("border-left");
implementedProperties.add("border-left-color");
implementedProperties.add("border-left-style");
implementedProperties.add("border-left-width");
implementedProperties.add("border-right");
implementedProperties.add("border-right-color");
implementedProperties.add("border-right-style");
implementedProperties.add("border-right-width");
implementedProperties.add("border-spacing");
implementedProperties.add("border-style");
implementedProperties.add("border-top");
implementedProperties.add("border-top-color");
implementedProperties.add("border-top-style");
implementedProperties.add("border-top-width");
implementedProperties.add("border-width");
implementedProperties.add("bottom");
implementedProperties.add("clear");
implementedProperties.add("clip");
implementedProperties.add("color");
implementedProperties.add("css-float");
implementedProperties.add("flex");
implementedProperties.add("flex-basis");
implementedProperties.add("flex-grow");
implementedProperties.add("flex-shrink");
implementedProperties.add("float");
implementedProperties.add("flood-color");
implementedProperties.add("font");
implementedProperties.add("font-family");
implementedProperties.add("font-size");
implementedProperties.add("font-style");
implementedProperties.add("font-variant");
implementedProperties.add("font-weight");
implementedProperties.add("height");
implementedProperties.add("left");
implementedProperties.add("lighting-color");
implementedProperties.add("line-height");
implementedProperties.add("margin");
implementedProperties.add("margin-bottom");
implementedProperties.add("margin-left");
implementedProperties.add("margin-right");
implementedProperties.add("margin-top");
implementedProperties.add("opacity");
implementedProperties.add("outline-color");
implementedProperties.add("padding");
implementedProperties.add("padding-bottom");
implementedProperties.add("padding-left");
implementedProperties.add("padding-right");
implementedProperties.add("padding-top");
implementedProperties.add("right");
implementedProperties.add("stop-color");
implementedProperties.add("text-line-through-color");
implementedProperties.add("text-overline-color");
implementedProperties.add("text-underline-color");
implementedProperties.add("top");
implementedProperties.add("webkit-border-after-color");
implementedProperties.add("webkit-border-before-color");
implementedProperties.add("webkit-border-end-color");
implementedProperties.add("webkit-border-start-color");
implementedProperties.add("webkit-column-rule-color");
implementedProperties.add("webkit-match-nearest-mail-blockquote-color");
implementedProperties.add("webkit-tap-highlight-color");
implementedProperties.add("webkit-text-emphasis-color");
implementedProperties.add("webkit-text-fill-color");
implementedProperties.add("webkit-text-stroke-color");
implementedProperties.add("width");
module.exports = implementedProperties;

152
node_modules/cssstyle/lib/named_colors.json generated vendored Normal file
View file

@ -0,0 +1,152 @@
[
"aliceblue",
"antiquewhite",
"aqua",
"aquamarine",
"azure",
"beige",
"bisque",
"black",
"blanchedalmond",
"blue",
"blueviolet",
"brown",
"burlywood",
"cadetblue",
"chartreuse",
"chocolate",
"coral",
"cornflowerblue",
"cornsilk",
"crimson",
"cyan",
"darkblue",
"darkcyan",
"darkgoldenrod",
"darkgray",
"darkgreen",
"darkgrey",
"darkkhaki",
"darkmagenta",
"darkolivegreen",
"darkorange",
"darkorchid",
"darkred",
"darksalmon",
"darkseagreen",
"darkslateblue",
"darkslategray",
"darkslategrey",
"darkturquoise",
"darkviolet",
"deeppink",
"deepskyblue",
"dimgray",
"dimgrey",
"dodgerblue",
"firebrick",
"floralwhite",
"forestgreen",
"fuchsia",
"gainsboro",
"ghostwhite",
"gold",
"goldenrod",
"gray",
"green",
"greenyellow",
"grey",
"honeydew",
"hotpink",
"indianred",
"indigo",
"ivory",
"khaki",
"lavender",
"lavenderblush",
"lawngreen",
"lemonchiffon",
"lightblue",
"lightcoral",
"lightcyan",
"lightgoldenrodyellow",
"lightgray",
"lightgreen",
"lightgrey",
"lightpink",
"lightsalmon",
"lightseagreen",
"lightskyblue",
"lightslategray",
"lightslategrey",
"lightsteelblue",
"lightyellow",
"lime",
"limegreen",
"linen",
"magenta",
"maroon",
"mediumaquamarine",
"mediumblue",
"mediumorchid",
"mediumpurple",
"mediumseagreen",
"mediumslateblue",
"mediumspringgreen",
"mediumturquoise",
"mediumvioletred",
"midnightblue",
"mintcream",
"mistyrose",
"moccasin",
"navajowhite",
"navy",
"oldlace",
"olive",
"olivedrab",
"orange",
"orangered",
"orchid",
"palegoldenrod",
"palegreen",
"paleturquoise",
"palevioletred",
"papayawhip",
"peachpuff",
"peru",
"pink",
"plum",
"powderblue",
"purple",
"rebeccapurple",
"red",
"rosybrown",
"royalblue",
"saddlebrown",
"salmon",
"sandybrown",
"seagreen",
"seashell",
"sienna",
"silver",
"skyblue",
"slateblue",
"slategray",
"slategrey",
"snow",
"springgreen",
"steelblue",
"tan",
"teal",
"thistle",
"tomato",
"turquoise",
"violet",
"wheat",
"white",
"whitesmoke",
"yellow",
"yellowgreen",
"transparent",
"currentcolor"
]

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

@ -0,0 +1,697 @@
/*********************************************************************
* 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';
const namedColors = require('./named_colors.json');
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,
};
// 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|ex|rem|vh|vw))$/;
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 colorRegEx4 = /^hsla?\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*(,\s*(-?\d+|-?\d*.\d+)\s*)?\)/;
var angleRegEx = /^([-+]?[0-9]*\.?[0-9]+)(deg|grad|rad)$/;
// 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;
}
if (colorRegEx4.test(val)) {
return exports.TYPES.COLOR;
}
// could still be a color, one of the standard keyword colors
val = val.toLowerCase();
if (namedColors.includes(val)) {
return exports.TYPES.COLOR;
}
switch (val) {
// 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,
hue,
saturation,
lightness,
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 + ')';
}
res = colorRegEx4.exec(val);
if (res) {
const [, _hue, _saturation, _lightness, _alphaString = ''] = res;
const _alpha = parseFloat(_alphaString.replace(',', '').trim());
if (!_hue || !_saturation || !_lightness) {
return undefined;
}
hue = parseFloat(_hue);
saturation = parseInt(_saturation, 10);
lightness = parseInt(_lightness, 10);
if (_alpha && numberRegEx.test(_alpha)) {
alpha = parseFloat(_alpha);
}
if (!_alphaString || alpha === 1) {
return 'hsl(' + hue + ', ' + saturation + '%, ' + lightness + '%)';
}
return 'hsla(' + hue + ', ' + saturation + '%, ' + lightness + '%, ' + 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, i) {
var part_valid = false;
Object.keys(shorthand_for).forEach(function(property) {
if (shorthand_for[property].isValid(part, i)) {
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;
var first_segment = /^\([^-]\)-/;
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;
};

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

File diff suppressed because it is too large Load diff

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

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

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

@ -0,0 +1,19 @@
'use strict';
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.definition = {
set: shorthandSetter('background', shorthand_for),
get: shorthandGetter('background', shorthand_for),
enumerable: true,
configurable: true,
};

View file

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

View file

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

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

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

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

@ -0,0 +1,17 @@
'use strict';
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthand_for = {
'border-bottom-width': require('./borderBottomWidth'),
'border-bottom-style': require('./borderBottomStyle'),
'border-bottom-color': require('./borderBottomColor'),
};
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,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,
};

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

@ -0,0 +1,26 @@
'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.definition = {
set: function(v) {
this._setProperty('border-collapse', parse(v));
},
get: function() {
return this.getPropertyValue('border-collapse');
},
enumerable: true,
configurable: true,
};

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

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

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

@ -0,0 +1,17 @@
'use strict';
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthand_for = {
'border-left-width': require('./borderLeftWidth'),
'border-left-style': require('./borderLeftStyle'),
'border-left-color': require('./borderLeftColor'),
};
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,
};

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

@ -0,0 +1,17 @@
'use strict';
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthand_for = {
'border-right-width': require('./borderRightWidth'),
'border-right-style': require('./borderRightStyle'),
'border-right-color': require('./borderRightColor'),
};
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,
};

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

@ -0,0 +1,41 @@
'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 === 0) {
return '0px';
}
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.definition = {
set: function(v) {
this._setProperty('border-spacing', parse(v));
},
get: function() {
return this.getPropertyValue('border-spacing');
},
enumerable: true,
configurable: true,
};

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

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

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

@ -0,0 +1,17 @@
'use strict';
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthand_for = {
'border-top-width': require('./borderTopWidth'),
'border-top-style': require('./borderTopStyle'),
'border-top-color': require('./borderTopColor'),
};
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,
};

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,
};

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

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

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,
};

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

@ -0,0 +1,47 @@
'use strict';
var parseMeasurement = require('../parsers').parseMeasurement;
var shape_regex = /^rect\((.*)\)$/i;
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,
};

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,
};

45
node_modules/cssstyle/lib/properties/flex.js generated vendored Normal file
View file

@ -0,0 +1,45 @@
'use strict';
var shorthandParser = require('../parsers').shorthandParser;
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
var shorthand_for = {
'flex-grow': require('./flexGrow'),
'flex-shrink': require('./flexShrink'),
'flex-basis': require('./flexBasis'),
};
var myShorthandSetter = shorthandSetter('flex', shorthand_for);
module.exports.isValid = function isValid(v) {
return shorthandParser(v, shorthand_for) !== undefined;
};
module.exports.definition = {
set: function(v) {
var normalizedValue = String(v)
.trim()
.toLowerCase();
if (normalizedValue === 'none') {
myShorthandSetter.call(this, '0 0 auto');
return;
}
if (normalizedValue === 'initial') {
myShorthandSetter.call(this, '0 1 auto');
return;
}
if (normalizedValue === 'auto') {
this.removeProperty('flex-grow');
this.removeProperty('flex-shrink');
this.setProperty('flex-basis', normalizedValue);
return;
}
myShorthandSetter.call(this, v);
},
get: shorthandGetter('flex', shorthand_for),
enumerable: true,
configurable: true,
};

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

@ -0,0 +1,28 @@
'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.isValid = function isValid(v) {
return parse(v) !== undefined;
};
module.exports.definition = {
set: function(v) {
this._setProperty('flex-basis', parse(v));
},
get: function() {
return this.getPropertyValue('flex-basis');
},
enumerable: true,
configurable: true,
};

19
node_modules/cssstyle/lib/properties/flexGrow.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
'use strict';
var parseNumber = require('../parsers').parseNumber;
var POSITION_AT_SHORTHAND = require('../constants').POSITION_AT_SHORTHAND;
module.exports.isValid = function isValid(v, positionAtFlexShorthand) {
return parseNumber(v) !== undefined && positionAtFlexShorthand === POSITION_AT_SHORTHAND.first;
};
module.exports.definition = {
set: function(v) {
this._setProperty('flex-grow', parseNumber(v));
},
get: function() {
return this.getPropertyValue('flex-grow');
},
enumerable: true,
configurable: true,
};

19
node_modules/cssstyle/lib/properties/flexShrink.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
'use strict';
var parseNumber = require('../parsers').parseNumber;
var POSITION_AT_SHORTHAND = require('../constants').POSITION_AT_SHORTHAND;
module.exports.isValid = function isValid(v, positionAtFlexShorthand) {
return parseNumber(v) !== undefined && positionAtFlexShorthand === POSITION_AT_SHORTHAND.second;
};
module.exports.definition = {
set: function(v) {
this._setProperty('flex-shrink', parseNumber(v));
},
get: function() {
return this.getPropertyValue('flex-shrink');
},
enumerable: true,
configurable: true,
};

12
node_modules/cssstyle/lib/properties/float.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,
};

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,
};

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

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

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

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

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,
};

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

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

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,
};

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,
};

14
node_modules/cssstyle/lib/properties/lightingColor.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('lighting-color', parseColor(v));
},
get: function() {
return this.getPropertyValue('lighting-color');
},
enumerable: true,
configurable: true,
};

26
node_modules/cssstyle/lib/properties/lineHeight.js generated vendored Normal file
View file

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

68
node_modules/cssstyle/lib/properties/margin.js generated vendored Normal file
View file

@ -0,0 +1,68 @@
'use strict';
var parsers = require('../parsers.js');
var TYPES = parsers.TYPES;
var isValid = function(v) {
if (v.toLowerCase() === 'auto') {
return true;
}
var type = parsers.valueType(v);
return (
type === TYPES.LENGTH ||
type === TYPES.PERCENT ||
(type === TYPES.INTEGER && (v === '0' || v === 0))
);
};
var parser = function(v) {
var V = v.toLowerCase();
if (V === 'auto') {
return V;
}
return parsers.parseMeasurement(v);
};
var mySetter = parsers.implicitSetter('margin', '', isValid, parser);
var myGlobal = parsers.implicitSetter(
'margin',
'',
function() {
return true;
},
function(v) {
return v;
}
);
module.exports.definition = {
set: function(v) {
if (typeof v === 'number') {
v = String(v);
}
if (typeof v !== 'string') {
return;
}
var V = v.toLowerCase();
switch (V) {
case 'inherit':
case 'initial':
case 'unset':
case '':
myGlobal.call(this, V);
break;
default:
mySetter.call(this, v);
break;
}
},
get: function() {
return this.getPropertyValue('margin');
},
enumerable: true,
configurable: true,
};
module.exports.isValid = isValid;
module.exports.parser = parser;

13
node_modules/cssstyle/lib/properties/marginBottom.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var margin = require('./margin.js');
var parsers = require('../parsers.js');
module.exports.definition = {
set: parsers.subImplicitSetter('margin', 'bottom', margin.isValid, margin.parser),
get: function() {
return this.getPropertyValue('margin-bottom');
},
enumerable: true,
configurable: true,
};

13
node_modules/cssstyle/lib/properties/marginLeft.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var margin = require('./margin.js');
var parsers = require('../parsers.js');
module.exports.definition = {
set: parsers.subImplicitSetter('margin', 'left', margin.isValid, margin.parser),
get: function() {
return this.getPropertyValue('margin-left');
},
enumerable: true,
configurable: true,
};

13
node_modules/cssstyle/lib/properties/marginRight.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var margin = require('./margin.js');
var parsers = require('../parsers.js');
module.exports.definition = {
set: parsers.subImplicitSetter('margin', 'right', margin.isValid, margin.parser),
get: function() {
return this.getPropertyValue('margin-right');
},
enumerable: true,
configurable: true,
};

13
node_modules/cssstyle/lib/properties/marginTop.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var margin = require('./margin.js');
var parsers = require('../parsers.js');
module.exports.definition = {
set: parsers.subImplicitSetter('margin', 'top', margin.isValid, margin.parser),
get: function() {
return this.getPropertyValue('margin-top');
},
enumerable: true,
configurable: true,
};

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

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

14
node_modules/cssstyle/lib/properties/outlineColor.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('outline-color', parseColor(v));
},
get: function() {
return this.getPropertyValue('outline-color');
},
enumerable: true,
configurable: true,
};

61
node_modules/cssstyle/lib/properties/padding.js generated vendored Normal file
View file

@ -0,0 +1,61 @@
'use strict';
var parsers = require('../parsers.js');
var TYPES = parsers.TYPES;
var isValid = function(v) {
var type = parsers.valueType(v);
return (
type === TYPES.LENGTH ||
type === TYPES.PERCENT ||
(type === TYPES.INTEGER && (v === '0' || v === 0))
);
};
var parser = function(v) {
return parsers.parseMeasurement(v);
};
var mySetter = parsers.implicitSetter('padding', '', isValid, parser);
var myGlobal = parsers.implicitSetter(
'padding',
'',
function() {
return true;
},
function(v) {
return v;
}
);
module.exports.definition = {
set: function(v) {
if (typeof v === 'number') {
v = String(v);
}
if (typeof v !== 'string') {
return;
}
var V = v.toLowerCase();
switch (V) {
case 'inherit':
case 'initial':
case 'unset':
case '':
myGlobal.call(this, V);
break;
default:
mySetter.call(this, v);
break;
}
},
get: function() {
return this.getPropertyValue('padding');
},
enumerable: true,
configurable: true,
};
module.exports.isValid = isValid;
module.exports.parser = parser;

13
node_modules/cssstyle/lib/properties/paddingBottom.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var padding = require('./padding.js');
var parsers = require('../parsers.js');
module.exports.definition = {
set: parsers.subImplicitSetter('padding', 'bottom', padding.isValid, padding.parser),
get: function() {
return this.getPropertyValue('padding-bottom');
},
enumerable: true,
configurable: true,
};

13
node_modules/cssstyle/lib/properties/paddingLeft.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var padding = require('./padding.js');
var parsers = require('../parsers.js');
module.exports.definition = {
set: parsers.subImplicitSetter('padding', 'left', padding.isValid, padding.parser),
get: function() {
return this.getPropertyValue('padding-left');
},
enumerable: true,
configurable: true,
};

13
node_modules/cssstyle/lib/properties/paddingRight.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var padding = require('./padding.js');
var parsers = require('../parsers.js');
module.exports.definition = {
set: parsers.subImplicitSetter('padding', 'right', padding.isValid, padding.parser),
get: function() {
return this.getPropertyValue('padding-right');
},
enumerable: true,
configurable: true,
};

13
node_modules/cssstyle/lib/properties/paddingTop.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var padding = require('./padding.js');
var parsers = require('../parsers.js');
module.exports.definition = {
set: parsers.subImplicitSetter('padding', 'top', padding.isValid, padding.parser),
get: function() {
return this.getPropertyValue('padding-top');
},
enumerable: true,
configurable: true,
};

14
node_modules/cssstyle/lib/properties/right.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('right', parseMeasurement(v));
},
get: function() {
return this.getPropertyValue('right');
},
enumerable: true,
configurable: true,
};

14
node_modules/cssstyle/lib/properties/stopColor.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('stop-color', parseColor(v));
},
get: function() {
return this.getPropertyValue('stop-color');
},
enumerable: true,
configurable: true,
};

View file

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

View file

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

View file

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

14
node_modules/cssstyle/lib/properties/top.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('top', parseMeasurement(v));
},
get: function() {
return this.getPropertyValue('top');
},
enumerable: true,
configurable: true,
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

24
node_modules/cssstyle/lib/properties/width.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('width', parse(v));
},
get: function() {
return this.getPropertyValue('width');
},
enumerable: true,
configurable: true,
};

View file

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

105
node_modules/cssstyle/package.json generated vendored Normal file
View file

@ -0,0 +1,105 @@
{
"_from": "cssstyle@^1.0.0",
"_id": "cssstyle@1.4.0",
"_inBundle": false,
"_integrity": "sha512-GBrLZYZ4X4x6/QEoBnIrqb8B/f5l4+8me2dkom/j1Gtbxy0kBv6OGzKuAsGM75bkGwGAFkt56Iwg28S3XTZgSA==",
"_location": "/cssstyle",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "cssstyle@^1.0.0",
"name": "cssstyle",
"escapedName": "cssstyle",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/jsdom"
],
"_resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.4.0.tgz",
"_shasum": "9d31328229d3c565c61e586b02041a28fccdccf1",
"_spec": "cssstyle@^1.0.0",
"_where": "E:\\github\\setup-java\\node_modules\\jsdom",
"bugs": {
"url": "https://github.com/jsakas/CSSStyleDeclaration/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Chad Walker",
"email": "chad@chad-cat-lore-eddie.com",
"url": "https://github.com/chad3814"
},
{
"name": "Rafał Ruciński",
"email": "fatfisz@gmail.com",
"url": "https://fatfisz.com"
},
{
"name": "Nikita Vasilyev",
"email": "me@elv1s.ru"
},
{
"name": "Davide P. Cervone"
},
{
"name": "Forbes Lindesay"
}
],
"dependencies": {
"cssom": "0.3.x"
},
"deprecated": false,
"description": "CSSStyleDeclaration Object Model implementation",
"devDependencies": {
"babel-generator": "~6.26.1",
"babel-traverse": "~6.26.0",
"babel-types": "~6.26.0",
"babylon": "~6.18.0",
"eslint": "5.13.0",
"eslint-config-prettier": "4.0.0",
"eslint-plugin-prettier": "3.0.1",
"nodeunit": "~0.11.3",
"npm-run-all": "^4.1.5",
"prettier": "1.16.4",
"request": "^2.88.0",
"resolve": "~1.8.1"
},
"directories": {
"lib": "./lib"
},
"homepage": "https://github.com/jsakas/CSSStyleDeclaration",
"keywords": [
"CSS",
"CSSStyleDeclaration",
"StyleSheet"
],
"license": "MIT",
"main": "./lib/CSSStyleDeclaration.js",
"maintainers": [
{
"name": "Jon Sakas",
"email": "jon.sakas@gmail.com",
"url": "https://jon.sakas.co/"
}
],
"name": "cssstyle",
"repository": {
"type": "git",
"url": "git+https://github.com/jsakas/CSSStyleDeclaration.git"
},
"scripts": {
"download": "node ./scripts/download_latest_properties.js && eslint lib/allProperties.js --fix",
"generate": "run-p generate:*",
"generate:implemented_properties": "node ./scripts/generate_implemented_properties.js",
"generate:properties": "node ./scripts/generate_properties.js",
"lint": "npm run generate && eslint . --max-warnings 0",
"lint:fix": "eslint . --fix --max-warnings 0",
"prepublishOnly": "npm run test-ci",
"test": "npm run generate && nodeunit tests",
"test-ci": "npm run lint && npm run test"
},
"version": "1.4.0"
}

View file

@ -0,0 +1,88 @@
'use strict';
/*
* W3C provides JSON list of all CSS properties and their status in the standard
*
* documentation: https://www.w3.org/Style/CSS/all-properties.en.html
* JSON url: ( https://www.w3.org/Style/CSS/all-properties.en.json )
*
* Download that file, filter out duplicates and filter the properties based on the wanted standard level
*
* ED - Editors' Draft (not a W3C Technical Report)
* FPWD - First Public Working Draft
* WD - Working Draft
* LC - Last Call Working Draft
* CR - Candidate Recommendation
* PR - Proposed Recommendation
* REC - Recommendation
* NOTE - Working Group Note
*/
var fs = require('fs');
var path = require('path');
var request = require('request');
const { camelToDashed } = require('../lib/parsers');
var url = 'https://www.w3.org/Style/CSS/all-properties.en.json';
console.log('Downloading CSS properties...');
function toCamelCase(propName) {
return propName.replace(/-([a-z])/g, function(g) {
return g[1].toUpperCase();
});
}
request(url, function(error, response, body) {
if (!error && response.statusCode === 200) {
var allCSSProperties = JSON.parse(body);
// Filter out all properties newer than Working Draft
var workingDraftAndOlderProperties = allCSSProperties.filter(function(cssProp) {
// TODO: --* css Needs additional logic to this module, so filter it out for now
return cssProp.status !== 'ED' && cssProp.status !== 'FPWD' && cssProp.property !== '--*';
});
// Remove duplicates, there can be many properties in different states of standard
// and add only property names to the list
var CSSpropertyNames = [];
workingDraftAndOlderProperties.forEach(function(cssProp) {
const camelCaseName = toCamelCase(cssProp.property);
if (CSSpropertyNames.indexOf(camelCaseName) === -1) {
CSSpropertyNames.push(camelCaseName);
}
});
var out_file = fs.createWriteStream(path.resolve(__dirname, './../lib/allProperties.js'), {
encoding: 'utf-8',
});
var date_today = new Date();
out_file.write(
"'use strict';\n\n// autogenerated - " +
(date_today.getMonth() + 1 + '/' + date_today.getDate() + '/' + date_today.getFullYear()) +
'\n\n'
);
out_file.write('/*\n *\n * https://www.w3.org/Style/CSS/all-properties.en.html\n */\n\n');
out_file.write('var allProperties = new Set();\n');
out_file.write('module.exports = allProperties;\n');
CSSpropertyNames.forEach(function(property) {
out_file.write('allProperties.add(' + JSON.stringify(camelToDashed(property)) + ');\n');
});
out_file.end(function(err) {
if (err) {
throw err;
}
console.log('Generated ' + Object.keys(CSSpropertyNames).length + ' properties.');
});
} else {
throw error;
}
});

View file

@ -0,0 +1,61 @@
'use strict';
const fs = require('fs');
const path = require('path');
const t = require('babel-types');
const generate = require('babel-generator').default;
const camelToDashed = require('../lib/parsers').camelToDashed;
const dashedProperties = fs
.readdirSync(path.resolve(__dirname, '../lib/properties'))
.filter(propertyFile => propertyFile.substr(-3) === '.js')
.map(propertyFile => camelToDashed(propertyFile.replace('.js', '')));
const out_file = fs.createWriteStream(path.resolve(__dirname, '../lib/implementedProperties.js'), {
encoding: 'utf-8',
});
var date_today = new Date();
out_file.write(
"'use strict';\n\n// autogenerated - " +
(date_today.getMonth() + 1 + '/' + date_today.getDate() + '/' + date_today.getFullYear()) +
'\n\n'
);
out_file.write('/*\n *\n * https://www.w3.org/Style/CSS/all-properties.en.html\n */\n\n');
const statements = [];
statements.push(
t.variableDeclaration('var', [
t.variableDeclarator(
t.identifier('implementedProperties'),
t.newExpression(t.identifier('Set'), [])
),
])
);
dashedProperties.forEach(property => {
statements.push(
t.expressionStatement(
t.callExpression(
t.memberExpression(t.identifier('implementedProperties'), t.identifier('add')),
[t.stringLiteral(property)]
)
)
);
});
statements.push(
t.expressionStatement(
t.assignmentExpression(
'=',
t.memberExpression(t.identifier('module'), t.identifier('exports')),
t.identifier('implementedProperties')
)
)
);
out_file.write(generate(t.program(statements)).code + '\n');
out_file.end(function(err) {
if (err) {
throw err;
}
});

292
node_modules/cssstyle/scripts/generate_properties.js generated vendored Normal file
View file

@ -0,0 +1,292 @@
'use strict';
var fs = require('fs');
var path = require('path');
var babylon = require('babylon');
var t = require('babel-types');
var generate = require('babel-generator').default;
var traverse = require('babel-traverse').default;
var resolve = require('resolve');
var camelToDashed = require('../lib/parsers').camelToDashed;
var basename = path.basename;
var dirname = path.dirname;
var uniqueIndex = 0;
function getUniqueIndex() {
return uniqueIndex++;
}
var property_files = fs
.readdirSync(path.resolve(__dirname, '../lib/properties'))
.filter(function(property) {
return property.substr(-3) === '.js';
});
var out_file = fs.createWriteStream(path.resolve(__dirname, '../lib/properties.js'), {
encoding: 'utf-8',
});
var date_today = new Date();
out_file.write(
"'use strict';\n\n// autogenerated - " +
(date_today.getMonth() + 1 + '/' + date_today.getDate() + '/' + date_today.getFullYear()) +
'\n\n'
);
out_file.write('/*\n *\n * https://www.w3.org/Style/CSS/all-properties.en.html\n */\n\n');
function isModuleDotExports(node) {
return (
t.isMemberExpression(node, { computed: false }) &&
t.isIdentifier(node.object, { name: 'module' }) &&
t.isIdentifier(node.property, { name: 'exports' })
);
}
function isRequire(node, filename) {
if (
t.isCallExpression(node) &&
t.isIdentifier(node.callee, { name: 'require' }) &&
node.arguments.length === 1 &&
t.isStringLiteral(node.arguments[0])
) {
var relative = node.arguments[0].value;
var fullPath = resolve.sync(relative, { basedir: dirname(filename) });
return { relative: relative, fullPath: fullPath };
} else {
return false;
}
}
// step 1: parse all files and figure out their dependencies
var parsedFilesByPath = {};
property_files.map(function(property) {
var filename = path.resolve(__dirname, '../lib/properties/' + property);
var src = fs.readFileSync(filename, 'utf8');
property = basename(property, '.js');
var ast = babylon.parse(src);
var dependencies = [];
traverse(ast, {
enter(path) {
var r;
if ((r = isRequire(path.node, filename))) {
dependencies.push(r.fullPath);
}
},
});
parsedFilesByPath[filename] = {
filename: filename,
property: property,
ast: ast,
dependencies: dependencies,
};
});
// step 2: serialize the files in an order where dependencies are always above
// the files they depend on
var externalDependencies = [];
var parsedFiles = [];
var addedFiles = {};
function addFile(filename, dependencyPath) {
if (dependencyPath.indexOf(filename) !== -1) {
throw new Error(
'Circular dependency: ' +
dependencyPath
.slice(dependencyPath.indexOf(filename))
.concat([filename])
.join(' -> ')
);
}
var file = parsedFilesByPath[filename];
if (addedFiles[filename]) {
return;
}
if (!file) {
externalDependencies.push(filename);
} else {
file.dependencies.forEach(function(dependency) {
addFile(dependency, dependencyPath.concat([filename]));
});
parsedFiles.push(parsedFilesByPath[filename]);
}
addedFiles[filename] = true;
}
Object.keys(parsedFilesByPath).forEach(function(filename) {
addFile(filename, []);
});
// Step 3: add files to output
// renaming exports to local variables `moduleName_export_exportName`
// and updating require calls as appropriate
var moduleExportsByPath = {};
var statements = [];
externalDependencies.forEach(function(filename, i) {
var id = t.identifier(
'external_dependency_' + basename(filename, '.js').replace(/[^A-Za-z]/g, '') + '_' + i
);
moduleExportsByPath[filename] = { defaultExports: id };
var relativePath = path.relative(path.resolve(__dirname + '/../lib'), filename);
if (relativePath[0] !== '.') {
relativePath = './' + relativePath;
}
statements.push(
t.variableDeclaration('var', [
t.variableDeclarator(
id,
t.callExpression(t.identifier('require'), [t.stringLiteral(relativePath)])
),
])
);
});
function getRequireValue(node, file) {
var r, e;
// replace require("./foo").bar with the named export from foo
if (
t.isMemberExpression(node, { computed: false }) &&
(r = isRequire(node.object, file.filename))
) {
e = moduleExportsByPath[r.fullPath];
if (!e) {
return;
}
if (!e.namedExports) {
return t.memberExpression(e.defaultExports, node.property);
}
if (!e.namedExports[node.property.name]) {
throw new Error(r.relative + ' does not export ' + node.property.name);
}
return e.namedExports[node.property.name];
// replace require("./foo") with the default export of foo
} else if ((r = isRequire(node, file.filename))) {
e = moduleExportsByPath[r.fullPath];
if (!e) {
if (/^\.\.\//.test(r.relative)) {
node.arguments[0].value = r.relative.substr(1);
}
return;
}
return e.defaultExports;
}
}
parsedFiles.forEach(function(file) {
var namedExports = {};
var localVariableMap = {};
traverse(file.ast, {
enter(path) {
// replace require calls with the corresponding value
var r;
if ((r = getRequireValue(path.node, file))) {
path.replaceWith(r);
return;
}
// if we see `var foo = require('bar')` we can just inline the variable
// representing `require('bar')` wherever `foo` was used.
if (
t.isVariableDeclaration(path.node) &&
path.node.declarations.length === 1 &&
t.isIdentifier(path.node.declarations[0].id) &&
(r = getRequireValue(path.node.declarations[0].init, file))
) {
var newName = 'compiled_local_variable_reference_' + getUniqueIndex();
path.scope.rename(path.node.declarations[0].id.name, newName);
localVariableMap[newName] = r;
path.remove();
return;
}
// rename all top level functions to keep them local to the module
if (t.isFunctionDeclaration(path.node) && t.isProgram(path.parent)) {
path.scope.rename(path.node.id.name, file.property + '_local_fn_' + path.node.id.name);
return;
}
// rename all top level variables to keep them local to the module
if (t.isVariableDeclaration(path.node) && t.isProgram(path.parent)) {
path.node.declarations.forEach(function(declaration) {
path.scope.rename(
declaration.id.name,
file.property + '_local_var_' + declaration.id.name
);
});
return;
}
// replace module.exports.bar with a variable for the named export
if (
t.isMemberExpression(path.node, { computed: false }) &&
isModuleDotExports(path.node.object)
) {
var name = path.node.property.name;
var identifier = t.identifier(file.property + '_export_' + name);
path.replaceWith(identifier);
namedExports[name] = identifier;
}
},
});
traverse(file.ast, {
enter(path) {
if (
t.isIdentifier(path.node) &&
Object.prototype.hasOwnProperty.call(localVariableMap, path.node.name)
) {
path.replaceWith(localVariableMap[path.node.name]);
}
},
});
var defaultExports = t.objectExpression(
Object.keys(namedExports).map(function(name) {
return t.objectProperty(t.identifier(name), namedExports[name]);
})
);
moduleExportsByPath[file.filename] = {
namedExports: namedExports,
defaultExports: defaultExports,
};
statements.push(
t.variableDeclaration(
'var',
Object.keys(namedExports).map(function(name) {
return t.variableDeclarator(namedExports[name]);
})
)
);
statements.push.apply(statements, file.ast.program.body);
});
var propertyDefinitions = [];
parsedFiles.forEach(function(file) {
var dashed = camelToDashed(file.property);
propertyDefinitions.push(
t.objectProperty(
t.identifier(file.property),
t.identifier(file.property + '_export_definition')
)
);
if (file.property !== dashed) {
propertyDefinitions.push(
t.objectProperty(t.stringLiteral(dashed), t.identifier(file.property + '_export_definition'))
);
}
});
var definePropertiesCall = t.callExpression(
t.memberExpression(t.identifier('Object'), t.identifier('defineProperties')),
[t.identifier('prototype'), t.objectExpression(propertyDefinitions)]
);
statements.push(
t.expressionStatement(
t.assignmentExpression(
'=',
t.memberExpression(t.identifier('module'), t.identifier('exports')),
t.functionExpression(
null,
[t.identifier('prototype')],
t.blockStatement([t.expressionStatement(definePropertiesCall)])
)
)
)
);
out_file.write(generate(t.program(statements)).code + '\n');
out_file.end(function(err) {
if (err) {
throw err;
}
});

669
node_modules/cssstyle/tests/tests.js generated vendored Normal file
View file

@ -0,0 +1,669 @@
'use strict';
var cssstyle = require('../lib/CSSStyleDeclaration');
var { dashedToCamelCase } = require('../lib/parsers');
var dashedProperties = [
...require('../lib/allProperties'),
...require('../lib/allExtraProperties'),
];
var allowedProperties = dashedProperties.map(dashedToCamelCase);
var implementedProperties = Array.from(require('../lib/implementedProperties')).map(
dashedToCamelCase
);
var invalidProperties = implementedProperties.filter(function(property) {
return !allowedProperties.includes(property);
});
module.exports = {
'Verify Has Only Valid Properties Implemented': function(test) {
test.expect(1);
test.ok(
invalidProperties.length === 0,
invalidProperties.length +
' invalid properties implemented: ' +
Array.from(invalidProperties).join(', ')
);
test.done();
},
'Verify Has All Properties': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(allowedProperties.length * 2);
allowedProperties.forEach(function(property) {
test.ok(style.__lookupGetter__(property), 'missing ' + property + ' property');
test.ok(style.__lookupSetter__(property), 'missing ' + property + ' property');
});
test.done();
},
'Verify Has All Dashed Properties': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(dashedProperties.length * 2);
dashedProperties.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%; height: 50vh;';
test.ok(4 === style.length, 'length is not 4');
test.ok(
'color: blue; background-color: red; width: 78%; height: 50vh;' === 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(9);
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 = '100vh';
test.ok('100vh' === style.height, 'height is not 100vh');
style.height = '100vw';
test.ok('100vw' === style.height, 'height is not 100vw');
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(9);
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);
style.color = 'hsla(0, 1%, 2%, 0.5)';
test.ok(
'hsla(0, 1%, 2%, 0.5)' === style.color,
'color is not hsla(0, 1%, 2%, 0.5) ' + style.color
);
style.color = 'hsl(0, 1%, 2%)';
test.ok('hsl(0, 1%, 2%)' === style.color, 'color is not hsl(0, 1%, 2%) ' + style.color);
style.color = 'rebeccapurple';
test.ok('rebeccapurple' === style.color, 'color is not rebeccapurple ' + style.color);
style.color = 'transparent';
test.ok('transparent' === style.color, 'color is not transparent ' + style.color);
style.color = 'currentcolor';
test.ok('currentcolor' === style.color, 'color is not currentcolor ' + style.color);
test.done();
},
'Test short hand properties with embedded spaces': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(4);
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
);
style = new cssstyle.CSSStyleDeclaration();
style.border = ' 1px solid black ';
test.ok(
'1px solid black' === style.border,
'multiple spaces not properly parsed: ' + style.border
);
test.done();
},
'Setting shorthand properties to an empty string should clear all dependent properties': function(
test
) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.borderWidth = '1px';
test.ok(
'border-width: 1px;' === style.cssText,
'cssText is not "border-width: 1px;": ' + style.cssText
);
style.border = '';
test.ok('' === style.cssText, 'cssText is not "": ' + style.cssText);
test.done();
},
'Setting implicit properties to an empty string should clear all dependent properties': function(
test
) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.borderTopWidth = '1px';
test.ok(
'border-top-width: 1px;' === style.cssText,
'cssText is not "border-top-width: 1px;": ' + style.cssText
);
style.borderWidth = '';
test.ok('' === style.cssText, 'cssText is not "": ' + style.cssText);
test.done();
},
'Setting a shorthand property, whose shorthands are implicit properties, to an empty string should clear all dependent properties': function(
test
) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(4);
style.borderTopWidth = '1px';
test.ok(
'border-top-width: 1px;' === style.cssText,
'cssText is not "border-top-width: 1px;": ' + style.cssText
);
style.border = '';
test.ok('' === style.cssText, 'cssText is not "": ' + style.cssText);
style.borderTop = '1px solid black';
test.ok(
'border-top: 1px solid black;' === style.cssText,
'cssText is not "border-top: 1px solid black;": ' + style.cssText
);
style.border = '';
test.ok('' === style.cssText, 'cssText is not "": ' + style.cssText);
test.done();
},
'Setting border values to "none" should clear dependent values': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(8);
style.borderTopWidth = '1px';
test.ok(
'border-top-width: 1px;' === style.cssText,
'cssText is not "border-top-width: 1px;": ' + style.cssText
);
style.border = 'none';
test.ok('' === style.cssText, 'cssText is not "": ' + style.cssText);
style.borderTopWidth = '1px';
test.ok(
'border-top-width: 1px;' === style.cssText,
'cssText is not "border-top-width: 1px;": ' + style.cssText
);
style.borderTopStyle = 'none';
test.ok('' === style.cssText, 'cssText is not "": ' + style.cssText);
style.borderTopWidth = '1px';
test.ok(
'border-top-width: 1px;' === style.cssText,
'cssText is not "border-top-width: 1px;": ' + style.cssText
);
style.borderTop = 'none';
test.ok('' === style.cssText, 'cssText is not "": ' + style.cssText);
style.borderTopWidth = '1px';
style.borderLeftWidth = '1px';
test.ok(
'border-top-width: 1px; border-left-width: 1px;' === style.cssText,
'cssText is not "border-top-width: 1px; border-left-width: 1px;": ' + style.cssText
);
style.borderTop = 'none';
test.ok(
'border-left-width: 1px;' === style.cssText,
'cssText is not "border-left-width: 1px;": ' + style.cssText
);
test.done();
},
'Setting border to 0 should be okay': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(1);
style.border = 0;
test.ok('border: 0px;' === style.cssText, 'cssText is not "border: 0px;": ' + style.cssText);
test.done();
},
'Setting values implicit and shorthand properties via cssText and setProperty should propagate to dependent properties': function(
test
) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(4);
style.cssText = 'border: 1px solid black;';
test.ok(
'border: 1px solid black;' === style.cssText,
'cssText is not "border: 1px solid black;": ' + style.cssText
);
test.ok(
'1px solid black' === style.borderTop,
'borderTop is not "1px solid black": ' + style.borderTop
);
style.border = '';
test.ok('' === style.cssText, 'cssText is not "": ' + style.cssText);
style.setProperty('border', '1px solid black');
test.ok(
'border: 1px solid black;' === style.cssText,
'cssText is not "border: 1px solid black;": ' + style.cssText
);
test.done();
},
'Setting opacity should work': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(3);
style.setProperty('opacity', 0.75);
test.ok(
'opacity: 0.75;' === style.cssText,
'cssText is not "opacity: 0.75;": ' + style.cssText
);
style.opacity = '0.50';
test.ok('opacity: 0.5;' === style.cssText, 'cssText is not "opacity: 0.5;": ' + style.cssText);
style.opacity = 1.0;
test.ok('opacity: 1;' === style.cssText, 'cssText is not "opacity: 1;": ' + style.cssText);
test.done();
},
'Width and height of auto should work': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(4);
style.width = 'auto';
test.equal(style.cssText, 'width: auto;', 'cssText is not "width: auto;": ' + style.cssText);
test.equal(style.width, 'auto', 'width is not "auto": ' + style.width);
style = new cssstyle.CSSStyleDeclaration();
style.height = 'auto';
test.equal(style.cssText, 'height: auto;', 'cssText is not "height: auto;": ' + style.cssText);
test.equal(style.height, 'auto', 'height is not "auto": ' + style.height);
test.done();
},
'Padding and margin should set/clear shorthand properties': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
var parts = ['Top', 'Right', 'Bottom', 'Left'];
var testParts = function(name, v, V) {
style[name] = v;
for (var i = 0; i < 4; i++) {
var part = name + parts[i];
test.equal(V[i], style[part], part + ' is not "' + V[i] + '": "' + style[part] + '"');
}
test.equal(v, style[name], name + ' is not "' + v + '": "' + style[name] + '"');
style[name] = '';
};
test.expect(50);
testParts('padding', '1px', ['1px', '1px', '1px', '1px']);
testParts('padding', '1px 2%', ['1px', '2%', '1px', '2%']);
testParts('padding', '1px 2px 3px', ['1px', '2px', '3px', '2px']);
testParts('padding', '1px 2px 3px 4px', ['1px', '2px', '3px', '4px']);
style.paddingTop = style.paddingRight = style.paddingBottom = style.paddingLeft = '1px';
testParts('padding', '', ['', '', '', '']);
testParts('margin', '1px', ['1px', '1px', '1px', '1px']);
testParts('margin', '1px auto', ['1px', 'auto', '1px', 'auto']);
testParts('margin', '1px 2% 3px', ['1px', '2%', '3px', '2%']);
testParts('margin', '1px 2px 3px 4px', ['1px', '2px', '3px', '4px']);
style.marginTop = style.marginRight = style.marginBottom = style.marginLeft = '1px';
testParts('margin', '', ['', '', '', '']);
test.done();
},
'Padding and margin shorthands should set main properties': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
var parts = ['Top', 'Right', 'Bottom', 'Left'];
var testParts = function(name, v, V) {
var expect;
for (var i = 0; i < 4; i++) {
style[name] = v;
style[name + parts[i]] = V;
expect = v.split(/ /);
expect[i] = V;
expect = expect.join(' ');
test.equal(expect, style[name], name + ' is not "' + expect + '": "' + style[name] + '"');
}
};
test.expect(12);
testParts('padding', '1px 2px 3px 4px', '10px');
testParts('margin', '1px 2px 3px 4px', '10px');
testParts('margin', '1px 2px 3px 4px', 'auto');
test.done();
},
'Setting a value to 0 should return the string value': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(1);
style.setProperty('fill-opacity', 0);
test.ok('0' === style.fillOpacity, 'fillOpacity is not "0": ' + style.fillOpacity);
test.done();
},
'onChange callback should be called when the cssText changes': function(test) {
var style = new cssstyle.CSSStyleDeclaration(function(cssText) {
test.ok('opacity: 0;' === cssText, 'cssText is not "opacity: 0;": ' + cssText);
test.done();
});
test.expect(1);
style.setProperty('opacity', 0);
},
'Setting float should work the same as cssFloat': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(1);
style.float = 'left';
test.ok('left' === style.cssFloat, 'cssFloat is not "left": ' + style.cssFloat);
test.done();
},
'Setting improper css to cssText should not throw': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.cssText = 'color: ';
test.ok('' === style.cssText, "cssText wasn't cleared: " + style.cssText);
style.color = 'black';
style.cssText = 'float: ';
test.ok('' === style.cssText, "cssText wasn't cleared: " + style.cssText);
test.done();
},
'Make sure url parsing works with quotes': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(3);
style.backgroundImage = 'url(http://some/url/here1.png)';
test.ok(
'url(http://some/url/here1.png)' === style.backgroundImage,
"background-image wasn't url(http://some/url/here1.png): " + style.backgroundImage
);
style.backgroundImage = "url('http://some/url/here2.png')";
test.ok(
'url(http://some/url/here2.png)' === style.backgroundImage,
"background-image wasn't url(http://some/url/here2.png): " + style.backgroundImage
);
style.backgroundImage = 'url("http://some/url/here3.png")';
test.ok(
'url(http://some/url/here3.png)' === style.backgroundImage,
"background-image wasn't url(http://some/url/here3.png): " + style.backgroundImage
);
test.done();
},
'Make sure setting 0 to a padding or margin works': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.padding = 0;
test.equal(style.cssText, 'padding: 0px;', 'padding is not 0px');
style.margin = '1em';
style.marginTop = '0';
test.equal(style.marginTop, '0px', 'margin-top is not 0px');
test.done();
},
'Make sure setting ex units to a padding or margin works': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.padding = '1ex';
test.equal(style.cssText, 'padding: 1ex;', 'padding is not 1ex');
style.margin = '1em';
style.marginTop = '0.5ex';
test.equal(style.marginTop, '0.5ex', 'margin-top is not 0.5ex');
test.done();
},
'Make sure setting null to background works': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.background = 'red';
test.equal(style.cssText, 'background: red;', 'background is not red');
style.background = null;
test.equal(style.cssText, '', 'cssText is not empty');
test.done();
},
'Flex properties should keep their values': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.flexDirection = 'column';
test.equal(style.cssText, 'flex-direction: column;', 'flex-direction is not column');
style.flexDirection = 'row';
test.equal(style.cssText, 'flex-direction: row;', 'flex-direction is not column');
test.done();
},
'Make sure camelCase properties are not assigned with `.setProperty()`': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(1);
style.setProperty('fontSize', '12px');
test.equal(style.cssText, '', 'cssText is not empty');
test.done();
},
'Make sure casing is ignored in `.setProperty()`': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.setProperty('FoNt-SiZe', '12px');
test.equal(style.fontSize, '12px', 'font-size: 12px');
test.equal(style.getPropertyValue('font-size'), '12px', 'font-size: 12px');
test.done();
},
'Support non string entries in border-spacing': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(1);
style.borderSpacing = 0;
test.equal(style.cssText, 'border-spacing: 0px;', 'border-spacing is not 0');
test.done();
},
'Float should be valid property for `.setProperty()`': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.setProperty('float', 'left');
test.equal(style.float, 'left');
test.equal(style.getPropertyValue('float'), 'left', 'float: left');
test.done();
},
'Make sure flex-shrink works': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(3);
style.setProperty('flex-shrink', 0);
test.equal(style.getPropertyValue('flex-shrink'), '0', 'flex-shrink is not 0');
style.setProperty('flex-shrink', 1);
test.equal(style.getPropertyValue('flex-shrink'), '1', 'flex-shrink is not 1');
test.equal(style.cssText, 'flex-shrink: 1;', 'flex-shrink cssText is incorrect');
test.done();
},
'Make sure flex-grow works': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(2);
style.setProperty('flex-grow', 2);
test.equal(style.getPropertyValue('flex-grow'), '2', 'flex-grow is not 2');
test.equal(style.cssText, 'flex-grow: 2;', 'flex-grow cssText is incorrect');
test.done();
},
'Make sure flex-basis works': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(5);
style.setProperty('flex-basis', 0);
test.equal(style.getPropertyValue('flex-basis'), '0px', 'flex-basis is not 0px');
style.setProperty('flex-basis', '250px');
test.equal(style.getPropertyValue('flex-basis'), '250px', 'flex-basis is not 250px');
style.setProperty('flex-basis', '10em');
test.equal(style.getPropertyValue('flex-basis'), '10em', 'flex-basis is not 10em');
style.setProperty('flex-basis', '30%');
test.equal(style.getPropertyValue('flex-basis'), '30%', 'flex-basis is not 30%');
test.equal(style.cssText, 'flex-basis: 30%;', 'flex-basis cssText is incorrect');
test.done();
},
'Make sure shorthand flex works': function(test) {
var style = new cssstyle.CSSStyleDeclaration();
test.expect(19);
style.setProperty('flex', 'none');
test.equal(style.getPropertyValue('flex-grow'), '0', 'flex-grow is not 0 if flex: none;');
test.equal(style.getPropertyValue('flex-shrink'), '0', 'flex-shrink is not 0 if flex: none;');
test.equal(
style.getPropertyValue('flex-basis'),
'auto',
'flex-basis is not `auto` if flex: none;'
);
style.removeProperty('flex');
style.removeProperty('flex-basis');
style.setProperty('flex', 'auto');
test.equal(style.getPropertyValue('flex-grow'), '', 'flex-grow is not empty if flex: auto;');
test.equal(
style.getPropertyValue('flex-shrink'),
'',
'flex-shrink is not empty if flex: auto;'
);
test.equal(
style.getPropertyValue('flex-basis'),
'auto',
'flex-basis is not `auto` if flex: auto;'
);
style.removeProperty('flex');
style.setProperty('flex', '0 1 250px');
test.equal(style.getPropertyValue('flex'), '0 1 250px', 'flex value is not `0 1 250px`');
test.equal(style.getPropertyValue('flex-grow'), '0', 'flex-grow is not 0');
test.equal(style.getPropertyValue('flex-shrink'), '1', 'flex-shrink is not 1');
test.equal(style.getPropertyValue('flex-basis'), '250px', 'flex-basis is not 250px');
style.removeProperty('flex');
style.setProperty('flex', '2');
test.equal(style.getPropertyValue('flex-grow'), '2', 'flex-grow is not 2');
test.equal(style.getPropertyValue('flex-shrink'), '', 'flex-shrink is not empty');
test.equal(style.getPropertyValue('flex-basis'), '', 'flex-basis is not empty');
style.removeProperty('flex');
style.setProperty('flex', '20%');
test.equal(style.getPropertyValue('flex-grow'), '', 'flex-grow is not empty');
test.equal(style.getPropertyValue('flex-shrink'), '', 'flex-shrink is not empty');
test.equal(style.getPropertyValue('flex-basis'), '20%', 'flex-basis is not 20%');
style.removeProperty('flex');
style.setProperty('flex', '2 2');
test.equal(style.getPropertyValue('flex-grow'), '2', 'flex-grow is not 2');
test.equal(style.getPropertyValue('flex-shrink'), '2', 'flex-shrink is not 2');
test.equal(style.getPropertyValue('flex-basis'), '', 'flex-basis is not empty');
style.removeProperty('flex');
test.done();
},
};