You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cssstyle

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssstyle - npm Package Compare versions

Comparing version

to
4.4.0

lib/generated/allProperties.js

102

lib/allExtraProperties.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -8,61 +8,43 @@ /**

var allWebkitProperties = require('./allWebkitProperties');
const allWebkitProperties = require("./allWebkitProperties");
module.exports = new Set(
[
'background-position-x',
'background-position-y',
'background-repeat-x',
'background-repeat-y',
'color-interpolation',
'color-profile',
'color-rendering',
'css-float',
'enable-background',
'fill',
'fill-opacity',
'fill-rule',
'glyph-orientation-horizontal',
'image-rendering',
'kerning',
'marker',
'marker-end',
'marker-mid',
'marker-offset',
'marker-start',
'marks',
'pointer-events',
'shape-rendering',
'size',
'src',
'stop-color',
'stop-opacity',
'stroke',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'stroke-opacity',
'stroke-width',
'text-anchor',
'text-line-through',
'text-line-through-color',
'text-line-through-mode',
'text-line-through-style',
'text-line-through-width',
'text-overline',
'text-overline-color',
'text-overline-mode',
'text-overline-style',
'text-overline-width',
'text-rendering',
'text-underline',
'text-underline-color',
'text-underline-mode',
'text-underline-style',
'text-underline-width',
'unicode-range',
'vector-effect',
].concat(allWebkitProperties)
);
module.exports = new Set([
"background-position-x",
"background-position-y",
"background-repeat-x",
"background-repeat-y",
"color-interpolation",
"color-profile",
"color-rendering",
"enable-background",
"glyph-orientation-horizontal",
"kerning",
"marker-offset",
"marks",
"pointer-events",
"shape-rendering",
"size",
"src",
"stop-color",
"stop-opacity",
"text-anchor",
"text-line-through",
"text-line-through-color",
"text-line-through-mode",
"text-line-through-style",
"text-line-through-width",
"text-overline",
"text-overline-color",
"text-overline-mode",
"text-overline-style",
"text-overline-width",
"text-rendering",
"text-underline",
"text-underline-color",
"text-underline-mode",
"text-underline-style",
"text-underline-width",
"unicode-range",
"vector-effect",
...allWebkitProperties
]);

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -9,187 +9,107 @@ /**

module.exports = [
'animation',
'animation-delay',
'animation-direction',
'animation-duration',
'animation-fill-mode',
'animation-iteration-count',
'animation-name',
'animation-play-state',
'animation-timing-function',
'appearance',
'aspect-ratio',
'backface-visibility',
'background-clip',
'background-composite',
'background-origin',
'background-size',
'border-after',
'border-after-color',
'border-after-style',
'border-after-width',
'border-before',
'border-before-color',
'border-before-style',
'border-before-width',
'border-end',
'border-end-color',
'border-end-style',
'border-end-width',
'border-fit',
'border-horizontal-spacing',
'border-image',
'border-radius',
'border-start',
'border-start-color',
'border-start-style',
'border-start-width',
'border-vertical-spacing',
'box-align',
'box-direction',
'box-flex',
'box-flex-group',
'box-lines',
'box-ordinal-group',
'box-orient',
'box-pack',
'box-reflect',
'box-shadow',
'color-correction',
'column-axis',
'column-break-after',
'column-break-before',
'column-break-inside',
'column-count',
'column-gap',
'column-rule',
'column-rule-color',
'column-rule-style',
'column-rule-width',
'columns',
'column-span',
'column-width',
'filter',
'flex-align',
'flex-direction',
'flex-flow',
'flex-item-align',
'flex-line-pack',
'flex-order',
'flex-pack',
'flex-wrap',
'flow-from',
'flow-into',
'font-feature-settings',
'font-kerning',
'font-size-delta',
'font-smoothing',
'font-variant-ligatures',
'highlight',
'hyphenate-character',
'hyphenate-limit-after',
'hyphenate-limit-before',
'hyphenate-limit-lines',
'hyphens',
'line-align',
'line-box-contain',
'line-break',
'line-clamp',
'line-grid',
'line-snap',
'locale',
'logical-height',
'logical-width',
'margin-after',
'margin-after-collapse',
'margin-before',
'margin-before-collapse',
'margin-bottom-collapse',
'margin-collapse',
'margin-end',
'margin-start',
'margin-top-collapse',
'marquee',
'marquee-direction',
'marquee-increment',
'marquee-repetition',
'marquee-speed',
'marquee-style',
'mask',
'mask-attachment',
'mask-box-image',
'mask-box-image-outset',
'mask-box-image-repeat',
'mask-box-image-slice',
'mask-box-image-source',
'mask-box-image-width',
'mask-clip',
'mask-composite',
'mask-image',
'mask-origin',
'mask-position',
'mask-position-x',
'mask-position-y',
'mask-repeat',
'mask-repeat-x',
'mask-repeat-y',
'mask-size',
'match-nearest-mail-blockquote-color',
'max-logical-height',
'max-logical-width',
'min-logical-height',
'min-logical-width',
'nbsp-mode',
'overflow-scrolling',
'padding-after',
'padding-before',
'padding-end',
'padding-start',
'perspective',
'perspective-origin',
'perspective-origin-x',
'perspective-origin-y',
'print-color-adjust',
'region-break-after',
'region-break-before',
'region-break-inside',
'region-overflow',
'rtl-ordering',
'svg-shadow',
'tap-highlight-color',
'text-combine',
'text-decorations-in-effect',
'text-emphasis',
'text-emphasis-color',
'text-emphasis-position',
'text-emphasis-style',
'text-fill-color',
'text-orientation',
'text-security',
'text-size-adjust',
'text-stroke',
'text-stroke-color',
'text-stroke-width',
'transform',
'transform-origin',
'transform-origin-x',
'transform-origin-y',
'transform-origin-z',
'transform-style',
'transition',
'transition-delay',
'transition-duration',
'transition-property',
'transition-timing-function',
'user-drag',
'user-modify',
'user-select',
'wrap',
'wrap-flow',
'wrap-margin',
'wrap-padding',
'wrap-shape-inside',
'wrap-shape-outside',
'wrap-through',
'writing-mode',
'zoom',
].map((prop) => 'webkit-' + prop);
"background-composite",
"border-after",
"border-after-color",
"border-after-style",
"border-after-width",
"border-before",
"border-before-color",
"border-before-style",
"border-before-width",
"border-end",
"border-end-color",
"border-end-style",
"border-end-width",
"border-fit",
"border-horizontal-spacing",
"border-start",
"border-start-color",
"border-start-style",
"border-start-width",
"border-vertical-spacing",
"color-correction",
"column-axis",
"column-break-after",
"column-break-before",
"column-break-inside",
"column-rule-color",
"flex-align",
"flex-item-align",
"flex-line-pack",
"flex-order",
"flex-pack",
"flex-wrap",
"font-size-delta",
"font-smoothing",
"highlight",
"hyphenate-limit-after",
"hyphenate-limit-before",
"locale",
"logical-height",
"logical-width",
"margin-after",
"margin-after-collapse",
"margin-before",
"margin-before-collapse",
"margin-bottom-collapse",
"margin-collapse",
"margin-end",
"margin-start",
"margin-top-collapse",
"marquee",
"marquee-direction",
"marquee-increment",
"marquee-repetition",
"marquee-speed",
"marquee-style",
"mask-attachment",
"mask-box-image-outset",
"mask-box-image-repeat",
"mask-box-image-slice",
"mask-box-image-source",
"mask-box-image-width",
"mask-position-x",
"mask-position-y",
"mask-repeat-x",
"mask-repeat-y",
"match-nearest-mail-blockquote-color",
"max-logical-height",
"max-logical-width",
"min-logical-height",
"min-logical-width",
"nbsp-mode",
"overflow-scrolling",
"padding-after",
"padding-before",
"padding-end",
"padding-start",
"perspective-origin-x",
"perspective-origin-y",
"region-break-after",
"region-break-before",
"region-break-inside",
"region-overflow",
"rtl-ordering",
"svg-shadow",
"tap-highlight-color",
"text-decorations-in-effect",
"text-emphasis-color",
"text-fill-color",
"text-security",
"text-size-adjust",
"text-stroke",
"text-stroke-color",
"text-stroke-width",
"transform",
"transform-origin-x",
"transform-origin-y",
"transform-origin-z",
"user-drag",
"user-modify",
"wrap",
"wrap-margin",
"wrap-padding",
"wrap-shape-inside",
"wrap-shape-outside",
"zoom"
].map((prop) => `-webkit-${prop}`);

@@ -1,270 +0,609 @@

/*********************************************************************
/**
* This is a fork from the CSS Style Declaration part of
* https://github.com/NV/CSSOM
********************************************************************/
'use strict';
var CSSOM = require('rrweb-cssom');
var allProperties = require('./allProperties');
var allExtraProperties = require('./allExtraProperties');
var implementedProperties = require('./implementedProperties');
var { dashedToCamelCase } = require('./parsers');
var getBasicPropertyDescriptor = require('./utils/getBasicPropertyDescriptor');
*/
"use strict";
const CSSOM = require("rrweb-cssom");
const allExtraProperties = require("./allExtraProperties");
const allProperties = require("./generated/allProperties");
const implementedProperties = require("./generated/implementedProperties");
const generatedProperties = require("./generated/properties");
const { hasVarFunc, parseKeyword, parseShorthand, prepareValue, splitValue } = require("./parsers");
const { dashedToCamelCase } = require("./utils/camelize");
const { getPropertyDescriptor } = require("./utils/propertyDescriptors");
/**
* @constructor
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
* @see https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface
*/
var CSSStyleDeclaration = function CSSStyleDeclaration(onChangeCallback) {
this._values = {};
this._importants = {};
this._length = 0;
this._onChange = onChangeCallback;
this._setInProgress = false;
};
CSSStyleDeclaration.prototype = {
constructor: CSSStyleDeclaration,
class 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.
* @param {Function} onChangeCallback
* @param {object} [opt]
* @param {object} [opt.context] - Window, Element or CSSRule.
*/
getPropertyValue: function (name) {
if (!this._values.hasOwnProperty(name)) {
return '';
}
return this._values[name].toString();
},
constructor(onChangeCallback, opt = {}) {
// Make constructor and internals non-enumerable.
Object.defineProperties(this, {
constructor: {
enumerable: false,
writable: true
},
/**
*
* @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;
// Window
_global: {
value: globalThis,
enumerable: false,
writable: true
},
// Element
_ownerNode: {
value: null,
enumerable: false,
writable: true
},
// CSSRule
_parentNode: {
value: null,
enumerable: false,
writable: true
},
_onChange: {
value: null,
enumerable: false,
writable: true
},
_values: {
value: new Map(),
enumerable: false,
writable: true
},
_priorities: {
value: new Map(),
enumerable: false,
writable: true
},
_length: {
value: 0,
enumerable: false,
writable: true
},
_computed: {
value: false,
enumerable: false,
writable: true
},
_readonly: {
value: false,
enumerable: false,
writable: true
},
_setInProgress: {
value: false,
enumerable: false,
writable: true
}
});
const { context } = opt;
if (context) {
if (typeof context.getComputedStyle === "function") {
this._global = context;
this._computed = true;
this._readonly = true;
} else if (context.nodeType === 1 && Object.hasOwn(context, "style")) {
this._global = context.ownerDocument.defaultView;
this._ownerNode = context;
} else if (Object.hasOwn(context, "parentRule")) {
this._parentRule = context;
// Find Window from the owner node of the StyleSheet.
const window = context?.parentStyleSheet?.ownerNode?.ownerDocument?.defaultView;
if (window) {
this._global = window;
}
}
}
if (value === null || value === '') {
this.removeProperty(name);
return;
if (typeof onChangeCallback === "function") {
this._onChange = onChangeCallback;
}
var isCustomProperty =
name.indexOf('--') === 0 ||
(typeof value === 'string' && /^var\(--[-\w]+,?.*\)$/.test(value));
if (isCustomProperty) {
this._setProperty(name, value, priority);
return;
}
get cssText() {
if (this._computed) {
return "";
}
var lowercaseName = name.toLowerCase();
if (!allProperties.has(lowercaseName) && !allExtraProperties.has(lowercaseName)) {
return;
const properties = [];
for (let i = 0; i < this._length; i++) {
const property = this[i];
const value = this.getPropertyValue(property);
const priority = this.getPropertyPriority(property);
if (priority === "important") {
properties.push(`${property}: ${value} !${priority};`);
} else {
properties.push(`${property}: ${value};`);
}
}
return properties.join(" ");
}
this[lowercaseName] = value;
this._importants[lowercaseName] = priority;
},
_setProperty: function (name, value, priority) {
if (value === undefined) {
set cssText(value) {
if (this._readonly) {
const msg = "cssText can not be modified.";
const name = "NoModificationAllowedError";
throw new this._global.DOMException(msg, name);
}
Array.prototype.splice.call(this, 0, this._length);
this._values.clear();
this._priorities.clear();
if (this._parentRule || (this._ownerNode && this._setInProgress)) {
return;
}
if (value === null || value === '') {
this.removeProperty(name);
this._setInProgress = true;
let dummyRule;
try {
dummyRule = CSSOM.parse(`#bogus{${value}}`).cssRules[0].style;
} catch {
// Malformed css, just return.
return;
}
var originalText;
if (this._onChange) {
originalText = this.cssText;
for (let i = 0; i < dummyRule.length; i++) {
const property = dummyRule[i];
this.setProperty(
property,
dummyRule.getPropertyValue(property),
dummyRule.getPropertyPriority(property)
);
}
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;
if (this._onChange && this.cssText !== originalText && !this._setInProgress) {
this._setInProgress = false;
if (typeof this._onChange === "function") {
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 '';
get length() {
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 length(len) {
for (let i = len; i < this._length; i++) {
delete this[i];
}
this._length = len;
}
var prevValue = this._values[name];
delete this._values[name];
delete this._importants[name];
// Readonly
get parentRule() {
return this._parentRule;
}
var index = Array.prototype.indexOf.call(this, name);
if (index < 0) {
return prevValue;
}
get cssFloat() {
return this.getPropertyValue("float");
}
// That's what WebKit and Opera do
Array.prototype.splice.call(this, index, 1);
set cssFloat(value) {
this._setProperty("float", value);
}
// That's what Firefox does
//this[index] = ""
/**
* @param {string} property
*/
getPropertyPriority(property) {
return this._priorities.get(property) || "";
}
if (this._onChange) {
this._onChange(this.cssText);
/**
* @param {string} property
*/
getPropertyValue(property) {
if (this._values.has(property)) {
return this._values.get(property).toString();
}
return prevValue;
},
return "";
}
/**
*
* @param {String} name
* @param {...number} args
*/
getPropertyPriority: function (name) {
return this._importants[name] || '';
},
item(...args) {
if (!args.length) {
const msg = "1 argument required, but only 0 present.";
throw new this._global.TypeError(msg);
}
let [index] = args;
index = parseInt(index);
if (Number.isNaN(index) || index < 0 || index >= this._length) {
return "";
}
return this[index];
}
getPropertyCSSValue: function () {
//FIXME
return;
},
/**
* element.style.overflow = "auto"
* element.style.getPropertyShorthand("overflow-x")
* -> "overflow"
* @param {string} property
*/
getPropertyShorthand: function () {
//FIXME
return;
},
removeProperty(property) {
if (this._readonly) {
const msg = `Property ${property} can not be modified.`;
const name = "NoModificationAllowedError";
throw new this._global.DOMException(msg, name);
}
if (!this._values.has(property)) {
return "";
}
const prevValue = this._values.get(property);
this._values.delete(property);
this._priorities.delete(property);
const index = Array.prototype.indexOf.call(this, property);
if (index >= 0) {
Array.prototype.splice.call(this, index, 1);
if (typeof this._onChange === "function") {
this._onChange(this.cssText);
}
}
return prevValue;
}
isPropertyImplicit: function () {
//FIXME
return;
},
/**
* http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-item
* @param {string} property
* @param {string} value
* @param {string?} [priority] - "important" or null
*/
item: function (index) {
index = parseInt(index, 10);
if (index < 0 || index >= this._length) {
return '';
setProperty(property, value, priority = null) {
if (this._readonly) {
const msg = `Property ${property} can not be modified.`;
const name = "NoModificationAllowedError";
throw new this._global.DOMException(msg, name);
}
return this[index];
},
};
value = prepareValue(value, this._global);
if (value === "") {
this[property] = "";
this.removeProperty(property);
return;
}
const isCustomProperty = property.startsWith("--");
if (isCustomProperty) {
this._setProperty(property, value);
return;
}
property = property.toLowerCase();
if (!allProperties.has(property) && !allExtraProperties.has(property)) {
return;
}
this[property] = value;
if (priority) {
this._priorities.set(property, priority);
} else {
this._priorities.delete(property);
}
}
}
// Internal methods
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;
_shorthandGetter: {
/**
* @param {string} property
* @param {object} shorthandFor
*/
value(property, shorthandFor) {
const parts = [];
for (const key of shorthandFor.keys()) {
const val = this.getPropertyValue(key);
if (hasVarFunc(val)) {
return "";
}
properties.push([name, ': ', value, priority, ';'].join(''));
if (val !== "") {
parts.push(val);
}
}
return properties.join(' ');
if (parts.length) {
return parts.join(" ");
}
if (this._values.has(property)) {
return this.getPropertyValue(property);
}
return "";
},
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
enumerable: false
},
_implicitGetter: {
/**
* @param {string} property
* @param {Array.<string>} positions
*/
value(property, positions = []) {
const parts = [];
for (const position of positions) {
const val = this.getPropertyValue(`${property}-${position}`);
if (val === "" || hasVarFunc(val)) {
return "";
}
parts.push(val);
}
if (!parts.length) {
return "";
}
switch (positions.length) {
case 4: {
const [top, right, bottom, left] = parts;
if (top === right && top === bottom && right === left) {
return top;
}
if (top !== right && top === bottom && right === left) {
return `${top} ${right}`;
}
if (top !== right && top !== bottom && right === left) {
return `${top} ${right} ${bottom}`;
}
return `${top} ${right} ${bottom} ${left}`;
}
case 2: {
const [x, y] = parts;
if (x === y) {
return x;
}
return `${x} ${y}`;
}
default:
return "";
}
},
enumerable: false
},
_setProperty: {
/**
* @param {string} property
* @param {string} val
* @param {string?} [priority]
*/
value(property, val, priority = null) {
if (typeof val !== "string") {
return;
}
this._setInProgress = true;
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)
);
if (val === "") {
this.removeProperty(property);
return;
}
this._setInProgress = false;
if (this._onChange) {
let originalText = "";
if (typeof this._onChange === "function") {
originalText = this.cssText;
}
if (this._values.has(property)) {
const index = Array.prototype.indexOf.call(this, property);
// The property already exists but is not indexed into `this` so add it.
if (index < 0) {
this[this._length] = property;
this._length++;
}
} else {
// New property.
this[this._length] = property;
this._length++;
}
this._values.set(property, val);
if (priority) {
this._priorities.set(property, priority);
} else {
this._priorities.delete(property);
}
if (
typeof this._onChange === "function" &&
this.cssText !== originalText &&
!this._setInProgress
) {
this._onChange(this.cssText);
}
},
enumerable: true,
configurable: true,
enumerable: false
},
parentRule: {
get: function () {
return null;
_shorthandSetter: {
/**
* @param {string} property
* @param {string} val
* @param {object} shorthandFor
*/
value(property, val, shorthandFor) {
val = prepareValue(val, this._global);
const obj = parseShorthand(val, shorthandFor);
if (!obj) {
return;
}
for (const subprop of Object.keys(obj)) {
// In case subprop is an implicit property, this will clear *its*
// subpropertiesX.
const 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.set(subprop, obj[subprop]);
}
}
for (const [subprop] of shorthandFor) {
if (!Object.hasOwn(obj, subprop)) {
this.removeProperty(subprop);
this._values.delete(subprop);
}
}
// 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);
const calculated = this._shorthandGetter(property, shorthandFor);
if (calculated !== "") {
this._setProperty(property, calculated);
}
return obj;
},
enumerable: true,
configurable: true,
enumerable: false
},
length: {
get: function () {
return this._length;
// Companion to shorthandSetter, but for the individual parts which takes
// position value in the middle.
_midShorthandSetter: {
/**
* @param {string} property
* @param {string} val
* @param {object} shorthandFor
* @param {Array.<string>} positions
*/
value(property, val, shorthandFor, positions = []) {
val = prepareValue(val, this._global);
const obj = this._shorthandSetter(property, val, shorthandFor);
if (!obj) {
return;
}
for (const position of positions) {
this.removeProperty(`${property}-${position}`);
this._values.set(`${property}-${position}`, val);
}
},
enumerable: false
},
_implicitSetter: {
/**
* 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];
* @param {string} prefix
* @param {string} part
* @param {string} val
* @param {Function} isValid
* @param {Function} parser
* @param {Array.<string>} positions
*/
value(prefix, part, val, isValid, parser, positions = []) {
val = prepareValue(val, this._global);
if (typeof val !== "string") {
return;
}
this._length = value;
part ||= "";
if (part) {
part = `-${part}`;
}
let parts = [];
if (val === "") {
parts.push(val);
} else {
const key = parseKeyword(val);
if (key) {
parts.push(key);
} else {
parts.push(...splitValue(val));
}
}
if (!parts.length || parts.length > positions.length || !parts.every(isValid)) {
return;
}
parts = parts.map((p) => parser(p));
this._setProperty(`${prefix}${part}`, parts.join(" "));
switch (positions.length) {
case 4:
if (parts.length === 1) {
parts.push(parts[0], parts[0], parts[0]);
} else if (parts.length === 2) {
parts.push(parts[0], parts[1]);
} else if (parts.length === 3) {
parts.push(parts[1]);
}
break;
case 2:
if (parts.length === 1) {
parts.push(parts[0]);
}
break;
default:
}
for (let i = 0; i < positions.length; i++) {
const property = `${prefix}-${positions[i]}${part}`;
this.removeProperty(property);
this._values.set(property, parts[i]);
}
},
enumerable: true,
configurable: true,
enumerable: false
},
});
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);
// Companion to implicitSetter, but for the individual parts.
// This sets the individual value, and checks to see if all sub-parts are
// set. If so, it sets the shorthand version and removes the individual parts
// from the cssText.
_subImplicitSetter: {
/**
* @param {string} prefix
* @param {string} part
* @param {string} val
* @param {Function} isValid
* @param {Function} parser
* @param {Array.<string>} positions
*/
value(prefix, part, val, isValid, parser, positions = []) {
val = prepareValue(val, this._global);
if (typeof val !== "string" || !isValid(val)) {
return;
}
val = parser(val);
const property = `${prefix}-${part}`;
this._setProperty(property, val);
const combinedPriority = this.getPropertyPriority(prefix);
const subparts = [];
for (const position of positions) {
subparts.push(`${prefix}-${position}`);
}
const parts = subparts.map((subpart) => this._values.get(subpart));
const priorities = subparts.map((subpart) => this.getPropertyPriority(subpart));
const [priority] = priorities;
// Combine into a single property if all values are set and have the same
// priority.
if (
priority === combinedPriority &&
parts.every((p) => p) &&
priorities.every((p) => p === priority)
) {
for (let i = 0; i < subparts.length; i++) {
this.removeProperty(subparts[i]);
this._values.set(subparts[i], parts[i]);
}
this._setProperty(prefix, parts.join(" "), priority);
} else {
this.removeProperty(prefix);
for (let i = 0; i < subparts.length; i++) {
// The property we're setting won't be important, the rest will either
// keep their priority or inherit it from the combined property
const subPriority = subparts[i] === property ? "" : priorities[i] || combinedPriority;
this._setProperty(subparts[i], parts[i], subPriority);
}
}
},
enumerable: false
}
});
allExtraProperties.forEach(function (property) {
// Properties
Object.defineProperties(CSSStyleDeclaration.prototype, generatedProperties);
// Additional properties
[...allProperties, ...allExtraProperties].forEach(function (property) {
if (!implementedProperties.has(property)) {
var declaration = getBasicPropertyDescriptor(property);
const declaration = getPropertyDescriptor(property);
Object.defineProperty(CSSStyleDeclaration.prototype, property, declaration);
Object.defineProperty(CSSStyleDeclaration.prototype, dashedToCamelCase(property), declaration);
const camel = dashedToCamelCase(property);
Object.defineProperty(CSSStyleDeclaration.prototype, camel, declaration);
if (/^webkit[A-Z]/.test(camel)) {
const pascal = camel.replace(/^webkit/, "Webkit");
Object.defineProperty(CSSStyleDeclaration.prototype, pascal, declaration);
}
}

@@ -271,0 +610,0 @@ });

@@ -1,216 +0,312 @@

/*********************************************************************
* 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';
/**
* 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 { resolve: resolveColor, utils } = require('@asamuzakjp/css-color');
const { resolve: resolveColor, utils } = require("@asamuzakjp/css-color");
const { cssCalc, isColor, isGradient, splitValue } = utils;
exports.TYPES = {
INTEGER: 1,
// CSS global values
// @see https://drafts.csswg.org/css-cascade-5/#defaulting-keywords
const GLOBAL_VALUE = Object.freeze(["initial", "inherit", "unset", "revert", "revert-layer"]);
// Numeric data types
const NUM_TYPE = Object.freeze({
UNDEFINED: 0,
VAR: 1,
NUMBER: 2,
LENGTH: 3,
PERCENT: 4,
URL: 5,
COLOR: 6,
STRING: 7,
ANGLE: 8,
KEYWORD: 9,
NULL_OR_EMPTY_STR: 10,
CALC: 11,
VAR: 12,
GRADIENT: 13,
};
LENGTH: 8,
ANGLE: 0x10,
CALC: 0x20
});
// regular expressions
var DIGIT = '(?:0|[1-9]\\d*)';
var NUMBER = `[+-]?(?:${DIGIT}(?:\\.\\d*)?|\\.\\d+)(?:e-?${DIGIT})?`;
var integerRegEx = new RegExp(`^[+-]?${DIGIT}$`);
var numberRegEx = new RegExp(`^${NUMBER}$`);
var lengthRegEx = new RegExp(
`^${NUMBER}(?:[cm]m|[dls]?v(?:[bhiw]|max|min)|in|p[ctx]|q|r?(?:[cl]h|cap|e[mx]|ic))$`
);
var percentRegEx = new RegExp(`^${NUMBER}%$`);
var angleRegEx = new RegExp(`^${NUMBER}(?:deg|g?rad|turn)$`);
var urlRegEx = /^url\(\s*((?:[^)]|\\\))*)\s*\)$/;
var stringRegEx = /^("[^"]*"|'[^']*')$/;
var varRegEx = /^var\(|(?<=[*/\s(])var\(/;
var calcRegEx =
// System colors
const SYS_COLOR = Object.freeze([
"accentcolor",
"accentcolortext",
"activetext",
"buttonborder",
"buttonface",
"buttontext",
"canvas",
"canvastext",
"field",
"fieldtext",
"graytext",
"highlight",
"highlighttext",
"linktext",
"mark",
"marktext",
"visitedtext",
"activeborder",
"activecaption",
"appworkspace",
"background",
"buttonhighlight",
"buttonshadow",
"captiontext",
"inactiveborder",
"inactivecaption",
"inactivecaptiontext",
"infobackground",
"infotext",
"menu",
"menutext",
"scrollbar",
"threeddarkshadow",
"threedface",
"threedhighlight",
"threedlightshadow",
"threedshadow",
"window",
"windowframe",
"windowtext"
]);
// Regular expressions
const DIGIT = "(?:0|[1-9]\\d*)";
const NUMBER = `[+-]?(?:${DIGIT}(?:\\.\\d*)?|\\.\\d+)(?:e-?${DIGIT})?`;
const unitRegEx = new RegExp(`^(${NUMBER})([a-z]+|%)?$`, "i");
const urlRegEx = /^url\(\s*((?:[^)]|\\\))*)\s*\)$/;
const keywordRegEx = /^[a-z]+(?:-[a-z]+)*$/i;
const stringRegEx = /^("[^"]*"|'[^']*')$/;
const varRegEx = /^var\(/;
const varContainedRegEx = /(?<=[*/\s(])var\(/;
const calcRegEx =
/^(?:a?(?:cos|sin|tan)|abs|atan2|calc|clamp|exp|hypot|log|max|min|mod|pow|rem|round|sign|sqrt)\(/;
// 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;
}
const getNumericType = function getNumericType(val) {
if (varRegEx.test(val)) {
return exports.TYPES.VAR;
return NUM_TYPE.VAR;
}
if (calcRegEx.test(val)) {
return exports.TYPES.CALC;
return NUM_TYPE.CALC;
}
if (stringRegEx.test(val)) {
return exports.TYPES.STRING;
if (unitRegEx.test(val)) {
const [, , unit] = unitRegEx.exec(val);
if (!unit) {
return NUM_TYPE.NUMBER;
}
if (unit === "%") {
return NUM_TYPE.PERCENT;
}
if (/^(?:[cm]m|[dls]?v(?:[bhiw]|max|min)|in|p[ctx]|q|r?(?:[cl]h|cap|e[mx]|ic))$/i.test(unit)) {
return NUM_TYPE.LENGTH;
}
if (/^(?:deg|g?rad|turn)$/i.test(unit)) {
return NUM_TYPE.ANGLE;
}
}
if (angleRegEx.test(val)) {
return exports.TYPES.ANGLE;
}
if (isColor(val)) {
return exports.TYPES.COLOR;
}
if (isGradient(val)) {
return exports.TYPES.GRADIENT;
}
switch (val.toLowerCase()) {
// 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;
}
return NUM_TYPE.UNDEFINED;
};
exports.parseInteger = function parseInteger(val) {
var type = exports.valueType(val);
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
return val;
// Prepare stringified value.
exports.prepareValue = function prepareValue(value, globalObject = globalThis) {
// `null` is converted to an empty string.
// @see https://webidl.spec.whatwg.org/#LegacyNullToEmptyString
if (value === null) {
return "";
}
if (type !== exports.TYPES.INTEGER) {
return undefined;
const type = typeof value;
switch (type) {
case "string":
return value.trim();
case "number":
return value.toString();
case "undefined":
return "undefined";
case "symbol":
throw new globalObject.TypeError("Can not convert symbol to string.");
default: {
const str = value.toString();
if (typeof str === "string") {
return str;
}
throw new globalObject.TypeError(`Can not convert ${type} to string.`);
}
}
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;
exports.hasVarFunc = function hasVarFunc(val) {
return varRegEx.test(val) || varContainedRegEx.test(val);
};
exports.parseNumber = function parseNumber(val, restrictToPositive = false) {
if (val === "") {
return "";
}
if (type !== exports.TYPES.NUMBER && type !== exports.TYPES.INTEGER) {
return undefined;
const type = getNumericType(val);
switch (type) {
case NUM_TYPE.VAR:
return val;
case NUM_TYPE.CALC:
return cssCalc(val, {
format: "specifiedValue"
});
case NUM_TYPE.NUMBER: {
const num = parseFloat(val);
if (restrictToPositive && num < 0) {
return;
}
return `${num}`;
}
default:
if (varContainedRegEx.test(val)) {
return val;
}
}
return String(parseFloat(val));
};
exports.parseLength = function parseLength(val) {
if (val === 0 || val === '0') {
return '0px';
exports.parseLength = function parseLength(val, restrictToPositive = false) {
if (val === "") {
return "";
}
var type = exports.valueType(val);
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
return val;
const type = getNumericType(val);
switch (type) {
case NUM_TYPE.VAR:
return val;
case NUM_TYPE.CALC:
return cssCalc(val, {
format: "specifiedValue"
});
case NUM_TYPE.NUMBER:
if (parseFloat(val) === 0) {
return "0px";
}
return;
case NUM_TYPE.LENGTH: {
const [, numVal, unit] = unitRegEx.exec(val);
const num = parseFloat(numVal);
if (restrictToPositive && num < 0) {
return;
}
return `${num}${unit.toLowerCase()}`;
}
default:
if (varContainedRegEx.test(val)) {
return val;
}
}
if (type !== exports.TYPES.LENGTH) {
return undefined;
}
return val;
};
exports.parsePercent = function parsePercent(val) {
if (val === 0 || val === '0') {
return '0%';
exports.parsePercent = function parsePercent(val, restrictToPositive = false) {
if (val === "") {
return "";
}
var type = exports.valueType(val);
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
return val;
const type = getNumericType(val);
switch (type) {
case NUM_TYPE.VAR:
return val;
case NUM_TYPE.CALC:
return cssCalc(val, {
format: "specifiedValue"
});
case NUM_TYPE.NUMBER:
if (parseFloat(val) === 0) {
return "0%";
}
return;
case NUM_TYPE.PERCENT: {
const [, numVal, unit] = unitRegEx.exec(val);
const num = parseFloat(numVal);
if (restrictToPositive && num < 0) {
return;
}
return `${num}${unit.toLowerCase()}`;
}
default:
if (varContainedRegEx.test(val)) {
return val;
}
}
if (type !== exports.TYPES.PERCENT) {
return undefined;
}
return val;
};
// either a length or a percent
exports.parseMeasurement = function parseMeasurement(val) {
var type = exports.valueType(val);
if (type === exports.TYPES.VAR) {
return val;
// Either a length or a percent.
exports.parseMeasurement = function parseMeasurement(val, restrictToPositive = false) {
if (val === "") {
return "";
}
if (type === exports.TYPES.CALC) {
return cssCalc(val, {
format: 'specifiedValue',
});
const type = getNumericType(val);
switch (type) {
case NUM_TYPE.VAR:
return val;
case NUM_TYPE.CALC:
return cssCalc(val, {
format: "specifiedValue"
});
case NUM_TYPE.NUMBER:
if (parseFloat(val) === 0) {
return "0px";
}
return;
case NUM_TYPE.LENGTH:
case NUM_TYPE.PERCENT: {
const [, numVal, unit] = unitRegEx.exec(val);
const num = parseFloat(numVal);
if (restrictToPositive && num < 0) {
return;
}
return `${num}${unit.toLowerCase()}`;
}
default:
if (varContainedRegEx.test(val)) {
return val;
}
}
var length = exports.parseLength(val);
if (length !== undefined) {
return length;
}
return exports.parsePercent(val);
};
exports.parseInheritingMeasurement = function parseInheritingMeasurement(v) {
if (String(v).toLowerCase() === 'auto') {
return 'auto';
exports.parseAngle = function parseAngle(val, normalizeDeg = false) {
if (val === "") {
return "";
}
if (String(v).toLowerCase() === 'inherit') {
return 'inherit';
const type = getNumericType(val);
switch (type) {
case NUM_TYPE.VAR:
return val;
case NUM_TYPE.CALC:
return cssCalc(val, {
format: "specifiedValue"
});
case NUM_TYPE.NUMBER:
if (parseFloat(val) === 0) {
return "0deg";
}
return;
case NUM_TYPE.ANGLE: {
let [, numVal, unit] = unitRegEx.exec(val);
numVal = parseFloat(numVal);
unit = unit.toLowerCase();
if (unit === "deg") {
if (normalizeDeg && numVal < 0) {
while (numVal < 0) {
numVal += 360;
}
}
numVal %= 360;
}
return `${numVal}${unit}`;
}
default:
if (varContainedRegEx.test(val)) {
return val;
}
}
return exports.parseMeasurement(v);
};
exports.parseUrl = function parseUrl(val) {
var type = exports.valueType(val);
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
if (val === "") {
return val;
}
var res = urlRegEx.exec(val);
// does it match the regex?
const res = urlRegEx.exec(val);
if (!res) {
return undefined;
return;
}
var str = res[1];
// if it starts with single or double quotes, does it end with the same?
let 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;
return;
}

@@ -220,11 +316,9 @@ if (str[0] === '"' || str[0] === "'") {

}
var urlstr = '';
var escaped = false;
var i;
for (i = 0; i < str.length; i++) {
let urlstr = "";
let escaped = false;
for (let i = 0; i < str.length; i++) {
switch (str[i]) {
case '\\':
case "\\":
if (escaped) {
urlstr += '\\\\';
urlstr += "\\\\";
escaped = false;

@@ -235,10 +329,10 @@ } else {

break;
case '(':
case ')':
case ' ':
case '\t':
case '\n':
case "(":
case ")":
case " ":
case "\t":
case "\n":
case "'":
if (!escaped) {
return undefined;
return;
}

@@ -250,3 +344,3 @@ urlstr += str[i];

if (!escaped) {
return undefined;
return;
}

@@ -261,115 +355,94 @@ urlstr += '\\"';

}
return 'url("' + urlstr + '")';
return `url("${urlstr}")`;
};
exports.parseString = function parseString(val) {
var type = exports.valueType(val);
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
return val;
if (val === "") {
return "";
}
if (type !== exports.TYPES.STRING) {
return undefined;
if (!stringRegEx.test(val)) {
return;
}
var i;
for (i = 1; i < val.length - 1; i++) {
val = val.substr(1, val.length - 2);
let str = "";
let escaped = false;
for (let i = 0; i < val.length; i++) {
switch (val[i]) {
case val[0]:
return undefined;
case '\\':
i++;
while (i < val.length - 1 && /[0-9A-Fa-f]/.test(val[i])) {
i++;
case "\\":
if (escaped) {
str += "\\\\";
escaped = false;
} else {
escaped = true;
}
break;
case '"':
str += '\\"';
escaped = false;
break;
default:
str += val[i];
escaped = false;
}
}
if (i >= val.length) {
return undefined;
}
return val;
return `"${str}"`;
};
exports.parseColor = function parseColor(val) {
var type = exports.valueType(val);
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
exports.parseKeyword = function parseKeyword(val, validKeywords = []) {
if (val === "") {
return "";
}
if (varRegEx.test(val)) {
return val;
}
if (/^[a-z]+$/i.test(val) && type === exports.TYPES.COLOR) {
val = val.toString().toLowerCase();
if (validKeywords.includes(val) || GLOBAL_VALUE.includes(val)) {
return val;
}
var res = resolveColor(val, {
format: 'specifiedValue',
});
if (res) {
return res;
}
return undefined;
};
exports.parseAngle = function parseAngle(val) {
var type = exports.valueType(val);
if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
exports.parseColor = function parseColor(val) {
if (val === "") {
return "";
}
if (varRegEx.test(val)) {
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) {
if (/^[a-z]+$/i.test(val) && SYS_COLOR.includes(val.toLowerCase())) {
return val;
}
if (type !== exports.TYPES.KEYWORD) {
return undefined;
const res = resolveColor(val, {
format: "specifiedValue"
});
if (res) {
return res;
}
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;
return exports.parseKeyword(val);
};
exports.parseImage = function parseImage(val) {
if (/^(?:none|inherit)$/i.test(val)) {
return val;
if (val === "") {
return "";
}
var type = exports.valueType(val);
if (type === exports.TYPES.NULL_OR_EMPTY_STR || type === exports.TYPES.VAR) {
if (varRegEx.test(val)) {
return val;
}
var values = splitValue(val, ',');
var isImage = !!values.length;
var i;
for (i = 0; i < values.length; i++) {
var image = values[i];
var t = exports.valueType(image);
if (t === exports.TYPES.NULL_OR_EMPTY_STR) {
return image;
if (keywordRegEx.test(val)) {
return exports.parseKeyword(val, ["none"]);
}
const values = splitValue(val, {
delimiter: ",",
preserveComment: varContainedRegEx.test(val)
});
let isImage = Boolean(values.length);
for (let i = 0; i < values.length; i++) {
const image = values[i];
if (image === "") {
return "";
}
if (t === exports.TYPES.GRADIENT || /^(?:none|inherit)$/i.test(image)) {
if (isGradient(image) || /^(?:none|inherit)$/i.test(image)) {
continue;
}
var imageUrl = exports.parseUrl(image);
if (exports.valueType(imageUrl) === exports.TYPES.URL) {
const imageUrl = exports.parseUrl(image);
if (imageUrl) {
values[i] = imageUrl;

@@ -382,291 +455,53 @@ } else {

if (isImage) {
return values.join(', ');
return values.join(", ");
}
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;
exports.parseShorthand = function parseShorthand(val, shorthandFor, preserve = false) {
const obj = {};
if (val === "" || exports.hasVarFunc(val)) {
for (const [property] of shorthandFor) {
obj[property] = "";
}
return obj;
}
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);
const key = exports.parseKeyword(val);
if (key) {
if (key === "inherit") {
return obj;
}
return;
}
const parts = splitValue(val);
const shorthandArr = [...shorthandFor];
for (const part of parts) {
let partValid = false;
for (let i = 0; i < shorthandArr.length; i++) {
const [property, value] = shorthandArr[i];
if (value.isValid(part)) {
partValid = true;
obj[property] = value.parse(part);
if (!preserve) {
shorthandArr.splice(i, 1);
break;
}
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 (!partValid) {
return;
}
}
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;
// Returns `false` for global values, e.g. "inherit".
exports.isValidColor = function isValidColor(val) {
if (SYS_COLOR.includes(val.toLowerCase())) {
return true;
}
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;
};
return isColor(val);
};
//
// 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 (v === null) {
v = '';
}
if (typeof v !== 'string') {
return undefined;
}
if (!isValid(v)) {
return undefined;
}
v = parser(v);
this._setProperty(property, v);
var combinedPriority = this.getPropertyPriority(prefix);
var parts = subparts.map((subpart) => this._values[subpart]);
var priorities = subparts.map((subpart) => this.getPropertyPriority(subpart));
// Combine into a single property if all values are set and have the same priority
if (
parts.every((p) => p !== '' && p != null) &&
priorities.every((p) => p === priorities[0]) &&
priorities[0] === combinedPriority
) {
for (var i = 0; i < subparts.length; i++) {
this.removeProperty(subparts[i]);
this._values[subparts[i]] = parts[i];
}
this._setProperty(prefix, parts.join(' '), priorities[0]);
} else {
this.removeProperty(prefix);
for (var j = 0; j < subparts.length; j++) {
// The property we're setting won't be important, the rest will either keep their priority or inherit it from the combined property
var priority = subparts[j] === property ? '' : priorities[j] || combinedPriority;
this._setProperty(subparts[j], parts[j], priority);
}
}
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;
};
// Splits value into an array.
// @see https://github.com/asamuzaK/cssColor/blob/main/src/js/util.ts
exports.splitValue = splitValue;

@@ -1,19 +0,46 @@

'use strict';
"use strict";
// FIXME:
// * support multiple backgrounds
// * also fix longhands
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
const parsers = require("../parsers");
const backgroundImage = require("./backgroundImage");
const backgroundPosition = require("./backgroundPosition");
const backgroundRepeat = require("./backgroundRepeat");
const backgroundAttachment = require("./backgroundAttachment");
const backgroundColor = require("./backgroundColor");
var shorthand_for = {
'background-color': require('./backgroundColor'),
'background-image': require('./backgroundImage'),
'background-repeat': require('./backgroundRepeat'),
'background-attachment': require('./backgroundAttachment'),
'background-position': require('./backgroundPosition'),
};
const shorthandFor = new Map([
["background-image", backgroundImage],
["background-position", backgroundPosition],
["background-repeat", backgroundRepeat],
["background-attachment", backgroundAttachment],
["background-color", backgroundColor]
]);
module.exports.definition = {
set: shorthandSetter('background', shorthand_for),
get: shorthandGetter('background', shorthand_for),
set(v) {
v = parsers.prepareValue(v, this._global);
if (v.toLowerCase() === "none" || parsers.hasVarFunc(v)) {
for (const [key] of shorthandFor) {
this._setProperty(key, "");
}
this._setProperty("background", v);
} else {
this._shorthandSetter("background", v, shorthandFor);
}
},
get() {
let val = this.getPropertyValue("background");
if (parsers.hasVarFunc(val)) {
return val;
}
val = this._shorthandGetter("background", shorthandFor);
if (parsers.hasVarFunc(val)) {
return "";
}
return val;
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,24 +0,32 @@

'use strict';
"use strict";
var parsers = require('../parsers');
const 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.parse = function parse(v) {
const keywords = ["fixed", "scroll", "local"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
if (!isValid(v)) {
return;
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("background", "");
this._setProperty("backgound-attachemnt", v);
} else {
this._setProperty("background-attachment", module.exports.parse(v));
}
this._setProperty('background-attachment', v);
},
get: function () {
return this.getPropertyValue('background-attachment');
get() {
return this.getPropertyValue("background-attachment");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,33 +0,35 @@

'use strict';
"use strict";
var parsers = require('../parsers');
const parsers = require("../parsers");
var parse = function parse(v) {
var parsed = parsers.parseColor(v);
if (parsed !== undefined) {
return parsed;
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
if (parsers.valueType(v) === parsers.TYPES.KEYWORD && v.toLowerCase() === 'inherit') {
return v;
}
return undefined;
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
return parse(v) !== undefined;
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
var parsed = parse(v);
if (parsed === undefined) {
return;
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("background", "");
this._setProperty("backgound-color", v);
} else {
this._setProperty("background-color", module.exports.parse(v));
}
this._setProperty('background-color', parsed);
},
get: function () {
return this.getPropertyValue('background-color');
get() {
return this.getPropertyValue("background-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,26 +0,31 @@

'use strict';
"use strict";
var parsers = require('../parsers');
const parsers = require("../parsers");
var parse = function parse(v) {
var parsed = parsers.parseImage(v);
if (parsed !== undefined) {
return parsed;
}
return undefined;
module.exports.parse = function parse(v) {
return parsers.parseImage(v);
};
module.exports.isValid = function isValid(v) {
return parse(v) !== undefined;
if (v === "" || typeof parsers.parseKeyword(v, ["none"]) === "string") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('background-image', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("background", "");
this._setProperty("backgound-image", v);
} else {
this._setProperty("background-image", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('background-image');
get() {
return this.getPropertyValue("background-image");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,58 +0,52 @@

'use strict';
"use strict";
var parsers = require('../parsers');
const parsers = require("../parsers");
var valid_keywords = ['top', 'center', 'bottom', 'left', 'right'];
var parse = function parse(v) {
if (v === '' || v === null) {
return undefined;
module.exports.parse = function parse(v) {
const parts = parsers.splitValue(v);
if (!parts.length || parts.length > 2) {
return;
}
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);
});
const validKeywordsX = ["left", "center", "right"];
const validKeywordsY = ["top", "center", "bottom"];
if (parts.length === 1) {
if (types[0] === parsers.TYPES.LENGTH || types[0] === parsers.TYPES.PERCENT) {
return v;
const dim = parsers.parseMeasurement(parts[0]);
if (dim) {
return dim;
}
if (types[0] === parsers.TYPES.KEYWORD) {
if (valid_keywords.indexOf(v.toLowerCase()) !== -1 || v.toLowerCase() === 'inherit') {
return v;
}
const validKeywords = new Set([...validKeywordsX, ...validKeywordsY]);
return parsers.parseKeyword(v, [...validKeywords]);
}
const [partX, partY] = parts;
const posX = parsers.parseMeasurement(partX) || parsers.parseKeyword(partX, validKeywordsX);
if (posX) {
const posY = parsers.parseMeasurement(partY) || parsers.parseKeyword(partY, validKeywordsY);
if (posY) {
return `${posX} ${posY}`;
}
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;
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('background-position', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("background", "");
this._setProperty("backgound-position", v);
} else {
this._setProperty("background-position", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('background-position');
get() {
return this.getPropertyValue("background-position");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,32 +0,32 @@

'use strict';
"use strict";
var parsers = require('../parsers');
const 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.parse = function parse(v) {
const keywords = ["repeat", "repeat-x", "repeat-y", "no-repeat", "space", "round"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
return parse(v) !== undefined;
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('background-repeat', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("background", "");
this._setProperty("backgound-repeat", v);
} else {
this._setProperty("background-repeat", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('background-repeat');
get() {
return this.getPropertyValue("background-repeat");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,33 +0,42 @@

'use strict';
"use strict";
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
const parsers = require("../parsers");
const borderWidth = require("./borderWidth");
const borderStyle = require("./borderStyle");
const borderColor = require("./borderColor");
var shorthand_for = {
'border-width': require('./borderWidth'),
'border-style': require('./borderStyle'),
'border-color': require('./borderColor'),
};
const shorthandFor = new Map([
["border-width", borderWidth],
["border-style", borderStyle],
["border-color", 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 = '';
set(v) {
v = parsers.prepareValue(v, this._global);
if (v.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;
if (parsers.hasVarFunc(v)) {
for (const [key] of shorthandFor) {
this._setProperty(key, "");
}
this._setProperty("border", v);
} else {
this._midShorthandSetter("border", v, shorthandFor, ["top", "right", "bottom", "left"]);
}
},
get: myShorthandGetter,
get() {
let val = this.getPropertyValue("border");
if (parsers.hasVarFunc(val)) {
return val;
}
val = this._shorthandGetter("border", shorthandFor);
if (parsers.hasVarFunc(val)) {
return "";
}
return val;
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,17 +0,40 @@

'use strict';
"use strict";
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
const parsers = require("../parsers");
const borderTopWidth = require("./borderTopWidth");
const borderTopStyle = require("./borderTopStyle");
const borderTopColor = require("./borderTopColor");
var shorthand_for = {
'border-bottom-width': require('./borderBottomWidth'),
'border-bottom-style': require('./borderBottomStyle'),
'border-bottom-color': require('./borderBottomColor'),
};
const shorthandFor = new Map([
["border-bottom-width", borderTopWidth],
["border-bottom-style", borderTopStyle],
["border-bottom-color", borderTopColor]
]);
module.exports.definition = {
set: shorthandSetter('border-bottom', shorthand_for),
get: shorthandGetter('border-bottom', shorthand_for),
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
for (const [key] of shorthandFor) {
this._setProperty(key, "");
}
this._setProperty("border", "");
this._setProperty("border-bottom", v);
} else {
this._shorthandSetter("border-bottom", v, shorthandFor);
}
},
get() {
let val = this.getPropertyValue("border-bottom");
if (parsers.hasVarFunc(val)) {
return val;
}
val = this._shorthandGetter("border-bottom", shorthandFor);
if (parsers.hasVarFunc(val)) {
return "";
}
return val;
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,16 +0,35 @@

'use strict';
"use strict";
var isValid = (module.exports.isValid = require('./borderColor').isValid);
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
this._setProperty('border-bottom-color', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-bottom", "");
this._setProperty("border-color", "");
}
this._setProperty("border-bottom-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-bottom-color');
get() {
return this.getPropertyValue("border-bottom-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,21 +0,50 @@

'use strict';
"use strict";
var isValid = require('./borderStyle').isValid;
module.exports.isValid = isValid;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = [
"none",
"hidden",
"dotted",
"dashed",
"solid",
"double",
"groove",
"ridge",
"inset",
"outset"
];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
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);
set(v) {
v = parsers.prepareValue(v, this._global);
const val = module.exports.parse(v);
if (val === "none" || val === "hidden") {
this._setProperty("border-bottom-style", "");
this._setProperty("border-bottom-color", "");
this._setProperty("border-bottom-width", "");
return;
}
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-bottom", "");
this._setProperty("border-style", "");
}
this._setProperty("border-bottom-style", val);
},
get: function () {
return this.getPropertyValue('border-bottom-style');
get() {
return this.getPropertyValue("border-bottom-style");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,16 +0,36 @@

'use strict';
"use strict";
var isValid = (module.exports.isValid = require('./borderWidth').isValid);
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = ["thin", "medium", "thick"];
const key = parsers.parseKeyword(v, keywords);
if (key) {
return key;
}
return parsers.parseLength(v, true);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
this._setProperty('border-bottom-width', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-bottom", "");
this._setProperty("border-width", "");
}
this._setProperty("border-bottom-width", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-bottom-width');
get() {
return this.getPropertyValue("border-bottom-width");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,26 +0,26 @@

'use strict';
"use strict";
var parsers = require('../parsers');
const 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;
module.exports.parse = function parse(v) {
return parsers.parseKeyword(v, ["collapse", "separate"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return undefined;
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('border-collapse', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("border-collapse", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-collapse');
get() {
return this.getPropertyValue("border-collapse");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,29 +0,43 @@

'use strict';
"use strict";
var parsers = require('../parsers');
var implicitSetter = require('../parsers').implicitSetter;
const parsers = require("../parsers");
var parser = function (v) {
var parsed = parsers.parseColor(v);
if (parsed !== undefined) {
return parsed;
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
if (parsers.valueType(v) === parsers.TYPES.KEYWORD && v.toLowerCase() === 'inherit') {
return v;
}
return undefined;
return parsers.parseKeyword(v);
};
module.exports.isValid = function parse(v) {
return parser(v) !== undefined;
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
var isValid = module.exports.isValid;
module.exports.definition = {
set: implicitSetter('border', 'color', isValid, parser),
get: function () {
return this.getPropertyValue('border-color');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-color", v);
} else {
const positions = ["top", "right", "bottom", "left"];
this._implicitSetter(
"border",
"color",
v,
module.exports.isValid,
module.exports.parse,
positions
);
}
},
get() {
return this.getPropertyValue("border-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,17 +0,40 @@

'use strict';
"use strict";
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
const parsers = require("../parsers");
const borderTopWidth = require("./borderTopWidth");
const borderTopStyle = require("./borderTopStyle");
const borderTopColor = require("./borderTopColor");
var shorthand_for = {
'border-left-width': require('./borderLeftWidth'),
'border-left-style': require('./borderLeftStyle'),
'border-left-color': require('./borderLeftColor'),
};
const shorthandFor = new Map([
["border-left-width", borderTopWidth],
["border-left-style", borderTopStyle],
["border-left-color", borderTopColor]
]);
module.exports.definition = {
set: shorthandSetter('border-left', shorthand_for),
get: shorthandGetter('border-left', shorthand_for),
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
for (const [key] of shorthandFor) {
this._setProperty(key, "");
}
this._setProperty("border", "");
this._setProperty("border-left", v);
} else {
this._shorthandSetter("border-left", v, shorthandFor);
}
},
get() {
let val = this.getPropertyValue("border-left");
if (parsers.hasVarFunc(val)) {
return val;
}
val = this._shorthandGetter("border-left", shorthandFor);
if (parsers.hasVarFunc(val)) {
return "";
}
return val;
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,16 +0,35 @@

'use strict';
"use strict";
var isValid = (module.exports.isValid = require('./borderColor').isValid);
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
this._setProperty('border-left-color', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-left", "");
this._setProperty("border-color", "");
}
this._setProperty("border-left-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-left-color');
get() {
return this.getPropertyValue("border-left-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,21 +0,50 @@

'use strict';
"use strict";
var isValid = require('./borderStyle').isValid;
module.exports.isValid = isValid;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = [
"none",
"hidden",
"dotted",
"dashed",
"solid",
"double",
"groove",
"ridge",
"inset",
"outset"
];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
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);
set(v) {
v = parsers.prepareValue(v, this._global);
const val = module.exports.parse(v);
if (val === "none" || val === "hidden") {
this._setProperty("border-left-style", "");
this._setProperty("border-left-color", "");
this._setProperty("border-left-width", "");
return;
}
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-left", "");
this._setProperty("border-style", "");
}
this._setProperty("border-left-style", val);
},
get: function () {
return this.getPropertyValue('border-left-style');
get() {
return this.getPropertyValue("border-left-style");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,16 +0,36 @@

'use strict';
"use strict";
var isValid = (module.exports.isValid = require('./borderWidth').isValid);
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = ["thin", "medium", "thick"];
const key = parsers.parseKeyword(v, keywords);
if (key) {
return key;
}
return parsers.parseLength(v, true);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
this._setProperty('border-left-width', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-left", "");
this._setProperty("border-width", "");
}
this._setProperty("border-left-width", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-left-width');
get() {
return this.getPropertyValue("border-left-width");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,17 +0,40 @@

'use strict';
"use strict";
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
const parsers = require("../parsers");
const borderTopWidth = require("./borderTopWidth");
const borderTopStyle = require("./borderTopStyle");
const borderTopColor = require("./borderTopColor");
var shorthand_for = {
'border-right-width': require('./borderRightWidth'),
'border-right-style': require('./borderRightStyle'),
'border-right-color': require('./borderRightColor'),
};
const shorthandFor = new Map([
["border-right-width", borderTopWidth],
["border-right-style", borderTopStyle],
["border-right-color", borderTopColor]
]);
module.exports.definition = {
set: shorthandSetter('border-right', shorthand_for),
get: shorthandGetter('border-right', shorthand_for),
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
for (const [key] of shorthandFor) {
this._setProperty(key, "");
}
this._setProperty("border", "");
this._setProperty("border-right", v);
} else {
this._shorthandSetter("border-right", v, shorthandFor);
}
},
get() {
let val = this.getPropertyValue("border-right");
if (parsers.hasVarFunc(val)) {
return val;
}
val = this._shorthandGetter("border-right", shorthandFor);
if (parsers.hasVarFunc(val)) {
return "";
}
return val;
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,16 +0,35 @@

'use strict';
"use strict";
var isValid = (module.exports.isValid = require('./borderColor').isValid);
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
this._setProperty('border-right-color', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-right", "");
this._setProperty("border-color", "");
}
this._setProperty("border-right-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-right-color');
get() {
return this.getPropertyValue("border-right-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,21 +0,50 @@

'use strict';
"use strict";
var isValid = require('./borderStyle').isValid;
module.exports.isValid = isValid;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = [
"none",
"hidden",
"dotted",
"dashed",
"solid",
"double",
"groove",
"ridge",
"inset",
"outset"
];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
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);
set(v) {
v = parsers.prepareValue(v, this._global);
const val = module.exports.parse(v);
if (val === "none" || val === "hidden") {
this._setProperty("border-right-style", "");
this._setProperty("border-right-color", "");
this._setProperty("border-right-width", "");
return;
}
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-right", "");
this._setProperty("border-style", "");
}
this._setProperty("border-right-style", val);
},
get: function () {
return this.getPropertyValue('border-right-style');
get() {
return this.getPropertyValue("border-right-style");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,16 +0,36 @@

'use strict';
"use strict";
var isValid = (module.exports.isValid = require('./borderWidth').isValid);
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = ["thin", "medium", "thick"];
const key = parsers.parseKeyword(v, keywords);
if (key) {
return key;
}
return parsers.parseLength(v, true);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
this._setProperty('border-right-width', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-right", "");
this._setProperty("border-width", "");
}
this._setProperty("border-right-width", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-right-width');
get() {
return this.getPropertyValue("border-right-width");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,41 +0,45 @@

'use strict';
"use strict";
var parsers = require('../parsers');
const 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;
module.exports.parse = function parse(v) {
if (v === "") {
return v;
}
if (v === 0) {
return '0px';
const key = parsers.parseKeyword(v);
if (key) {
return key;
}
if (v.toLowerCase() === 'inherit') {
return v;
const parts = parsers.splitValue(v);
if (!parts.length || parts.length > 2) {
return;
}
var parts = v.split(/\s+/);
if (parts.length !== 1 && parts.length !== 2) {
return undefined;
const val = [];
for (const part of parts) {
const dim = parsers.parseLength(part);
if (!dim) {
return;
}
val.push(dim);
}
parts.forEach(function (part) {
if (parsers.valueType(part) !== parsers.TYPES.LENGTH) {
return undefined;
}
});
return val.join(" ");
};
return v;
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('border-spacing', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("border-spacing", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-spacing');
get() {
return this.getPropertyValue("border-spacing");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,38 +0,54 @@

'use strict';
"use strict";
var implicitSetter = require('../parsers').implicitSetter;
const parsers = require("../parsers");
// 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);
module.exports.parse = function parse(v) {
const keywords = [
"none",
"hidden",
"dotted",
"dashed",
"solid",
"double",
"groove",
"ridge",
"inset",
"outset"
];
return parsers.parseKeyword(v, keywords);
};
var isValid = module.exports.isValid;
var parser = function (v) {
if (isValid(v)) {
return v.toLowerCase();
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return undefined;
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: implicitSetter('border', 'style', isValid, parser),
get: function () {
return this.getPropertyValue('border-style');
set(v) {
v = parsers.prepareValue(v, this._global);
if (v.toLowerCase() === "none") {
v = "";
}
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-style", v);
return;
}
const positions = ["top", "right", "bottom", "left"];
this._implicitSetter(
"border",
"style",
v,
module.exports.isValid,
module.exports.parse,
positions
);
},
get() {
return this.getPropertyValue("border-style");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,17 +0,40 @@

'use strict';
"use strict";
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
const parsers = require("../parsers");
const borderTopWidth = require("./borderTopWidth");
const borderTopStyle = require("./borderTopStyle");
const borderTopColor = require("./borderTopColor");
var shorthand_for = {
'border-top-width': require('./borderTopWidth'),
'border-top-style': require('./borderTopStyle'),
'border-top-color': require('./borderTopColor'),
};
const shorthandFor = new Map([
["border-top-width", borderTopWidth],
["border-top-style", borderTopStyle],
["border-top-color", borderTopColor]
]);
module.exports.definition = {
set: shorthandSetter('border-top', shorthand_for),
get: shorthandGetter('border-top', shorthand_for),
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
for (const [key] of shorthandFor) {
this._setProperty(key, "");
}
this._setProperty("border", "");
this._setProperty("border-top", v);
} else {
this._shorthandSetter("border-top", v, shorthandFor);
}
},
get() {
let val = this.getPropertyValue("border-top");
if (parsers.hasVarFunc(val)) {
return val;
}
val = this._shorthandGetter("border-top", shorthandFor);
if (parsers.hasVarFunc(val)) {
return "";
}
return val;
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,16 +0,35 @@

'use strict';
"use strict";
var isValid = (module.exports.isValid = require('./borderColor').isValid);
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
this._setProperty('border-top-color', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-top", "");
this._setProperty("border-color", "");
}
this._setProperty("border-top-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-top-color');
get() {
return this.getPropertyValue("border-top-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,21 +0,50 @@

'use strict';
"use strict";
var isValid = require('./borderStyle').isValid;
module.exports.isValid = isValid;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = [
"none",
"hidden",
"dotted",
"dashed",
"solid",
"double",
"groove",
"ridge",
"inset",
"outset"
];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
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);
set(v) {
v = parsers.prepareValue(v, this._global);
const val = module.exports.parse(v);
if (val === "none" || val === "hidden" || v === "") {
this._setProperty("border-top-style", "");
this._setProperty("border-top-color", "");
this._setProperty("border-top-width", "");
return;
}
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-top", "");
this._setProperty("border-style", "");
}
this._setProperty("border-top-style", val);
},
get: function () {
return this.getPropertyValue('border-top-style');
get() {
return this.getPropertyValue("border-top-style");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,17 +0,36 @@

'use strict';
"use strict";
var isValid = require('./borderWidth').isValid;
module.exports.isValid = isValid;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = ["thin", "medium", "thick"];
const key = parsers.parseKeyword(v, keywords);
if (key) {
return key;
}
return parsers.parseLength(v, true);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
if (isValid(v)) {
this._setProperty('border-top-width', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-top", "");
this._setProperty("border-width", "");
}
this._setProperty("border-top-width", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('border-top-width');
get() {
return this.getPropertyValue("border-top-width");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,46 +0,44 @@

'use strict';
"use strict";
var parsers = require('../parsers');
var implicitSetter = require('../parsers').implicitSetter;
const parsers = require("../parsers");
// 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;
module.exports.parse = function parse(v) {
const keywords = ["thin", "medium", "thick"];
const key = parsers.parseKeyword(v, keywords);
if (key) {
return key;
}
if (typeof v !== 'string') {
return false;
}
if (v === '') {
return true;
}
v = v.toLowerCase();
if (widths.indexOf(v) === -1) {
return false;
}
return true;
return parsers.parseLength(v, true);
};
var isValid = module.exports.isValid;
var parser = function (v) {
var length = parsers.parseLength(v);
if (length !== undefined) {
return length;
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
if (isValid(v)) {
return v.toLowerCase();
}
return undefined;
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: implicitSetter('border', 'width', isValid, parser),
get: function () {
return this.getPropertyValue('border-width');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("border", "");
this._setProperty("border-width", v);
} else {
const positions = ["top", "right", "bottom", "left"];
this._implicitSetter(
"border",
"width",
v,
module.exports.isValid,
module.exports.parse,
positions
);
}
},
get() {
return this.getPropertyValue("border-width");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseMeasurement = require('../parsers').parseInheritingMeasurement;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const dim = parsers.parseMeasurement(v);
if (dim) {
return dim;
}
return parsers.parseKeyword(v, ["auto"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('bottom', parseMeasurement(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("bottom", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('bottom');
get() {
return this.getPropertyValue("bottom");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,16 +0,40 @@

'use strict';
"use strict";
var parseKeyword = require('../parsers').parseKeyword;
const parsers = require("../parsers");
var clear_keywords = ['none', 'left', 'right', 'both', 'inherit'];
module.exports.parse = function parse(v) {
const keywords = [
"inline-start",
"inline-end",
"block-start",
"block-end",
"left",
"right",
"top",
"bottom",
"both-inline",
"both-block",
"both",
"none"
];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('clear', parseKeyword(v, clear_keywords));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("clear", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('clear');
get() {
return this.getPropertyValue("clear");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,47 +0,53 @@

'use strict';
"use strict";
// deprecated
// @see https://drafts.fxtf.org/css-masking/#clip-property
var parseMeasurement = require('../parsers').parseMeasurement;
const parsers = require("../parsers");
var shape_regex = /^rect\((.*)\)$/i;
var parse = function (val) {
if (val === '' || val === null) {
return val;
module.exports.parse = function parse(v) {
if (v === "") {
return v;
}
if (typeof val !== 'string') {
return undefined;
}
val = val.toLowerCase();
if (val === 'auto' || val === 'inherit') {
const val = parsers.parseKeyword(v, ["auto"]);
if (val) {
return val;
}
var matches = val.match(shape_regex);
// parse legacy <shape>
v = v.toLowerCase();
const matches = v.match(/^rect\(\s*(.*)\s*\)$/);
if (!matches) {
return undefined;
return;
}
var parts = matches[1].split(/\s*,\s*/);
const parts = matches[1].split(/\s*,\s*/);
if (parts.length !== 4) {
return undefined;
return;
}
var valid = parts.every(function (part, index) {
var measurement = parseMeasurement(part);
const valid = parts.every(function (part, index) {
const measurement = parsers.parseMeasurement(part.trim());
parts[index] = measurement;
return measurement !== undefined;
return typeof measurement === "string";
});
if (!valid) {
return undefined;
return;
}
parts = parts.join(', ');
return val.replace(matches[1], parts);
return `rect(${parts.join(", ")})`;
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('clip', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("clip", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('clip');
get() {
return this.getPropertyValue("clip");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('color');
get() {
return this.getPropertyValue("color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,43 +0,73 @@

'use strict';
"use strict";
var shorthandParser = require('../parsers').shorthandParser;
var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;
const parsers = require("../parsers");
const flexGrow = require("./flexGrow");
const flexShrink = require("./flexShrink");
const flexBasis = require("./flexBasis");
var shorthand_for = {
'flex-grow': require('./flexGrow'),
'flex-shrink': require('./flexShrink'),
'flex-basis': require('./flexBasis'),
const shorthandFor = new Map([
["flex-grow", flexGrow],
["flex-shrink", flexShrink],
["flex-basis", flexBasis]
]);
module.exports.parse = function parse(v) {
const key = parsers.parseKeyword(v, ["auto", "none"]);
if (key) {
if (key === "auto") {
return "1 1 auto";
}
if (key === "none") {
return "0 0 auto";
}
if (key === "initial") {
return "0 1 auto";
}
return;
}
const obj = parsers.parseShorthand(v, shorthandFor);
if (obj) {
const flex = {
"flex-grow": "1",
"flex-shrink": "1",
"flex-basis": "0%"
};
const items = Object.entries(obj);
for (const [property, value] of items) {
flex[property] = value;
}
return [...Object.values(flex)].join(" ");
}
};
var myShorthandSetter = shorthandSetter('flex', shorthand_for);
module.exports.isValid = function isValid(v) {
return shorthandParser(v, shorthand_for) !== undefined;
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
var normalizedValue = String(v).trim().toLowerCase();
if (normalizedValue === 'none') {
myShorthandSetter.call(this, '0 0 auto');
return;
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._shorthandSetter("flex", "", shorthandFor);
this._setProperty("flex", v);
} else {
this._shorthandSetter("flex", module.exports.parse(v), shorthandFor);
}
if (normalizedValue === 'initial') {
myShorthandSetter.call(this, '0 1 auto');
return;
},
get() {
let val = this.getPropertyValue("flex");
if (parsers.hasVarFunc(val)) {
return val;
}
if (normalizedValue === 'auto') {
this.removeProperty('flex-grow');
this.removeProperty('flex-shrink');
this.setProperty('flex-basis', normalizedValue);
return;
val = this._shorthandGetter("flex", shorthandFor);
if (parsers.hasVarFunc(val)) {
return "";
}
myShorthandSetter.call(this, v);
return val;
},
get: shorthandGetter('flex', shorthand_for),
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,28 +0,33 @@

'use strict';
"use strict";
var parseMeasurement = require('../parsers').parseMeasurement;
const parsers = require("../parsers");
function parse(v) {
if (String(v).toLowerCase() === 'auto') {
return 'auto';
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v);
if (val) {
return val;
}
if (String(v).toLowerCase() === 'inherit') {
return 'inherit';
}
return parseMeasurement(v);
}
const keywords = ["content", "auto", "min-content", "max-content"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
return parse(v) !== undefined;
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('flex-basis', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("flex", "");
this._setProperty("flex-basis", v);
} else {
this._setProperty("flex-basis", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('flex-basis');
get() {
return this.getPropertyValue("flex-basis");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,19 +0,28 @@

'use strict';
"use strict";
var parseNumber = require('../parsers').parseNumber;
var POSITION_AT_SHORTHAND = require('../constants').POSITION_AT_SHORTHAND;
const parsers = require("../parsers");
module.exports.isValid = function isValid(v, positionAtFlexShorthand) {
return parseNumber(v) !== undefined && positionAtFlexShorthand === POSITION_AT_SHORTHAND.first;
module.exports.parse = function parse(v) {
return parsers.parseNumber(v, true);
};
module.exports.isValid = function isValid(v) {
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('flex-grow', parseNumber(v));
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("flex", "");
this._setProperty("flex-grow", v);
} else {
this._setProperty("flex-grow", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('flex-grow');
get() {
return this.getPropertyValue("flex-grow");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,19 +0,28 @@

'use strict';
"use strict";
var parseNumber = require('../parsers').parseNumber;
var POSITION_AT_SHORTHAND = require('../constants').POSITION_AT_SHORTHAND;
const parsers = require("../parsers");
module.exports.isValid = function isValid(v, positionAtFlexShorthand) {
return parseNumber(v) !== undefined && positionAtFlexShorthand === POSITION_AT_SHORTHAND.second;
module.exports.parse = function parse(v) {
return parsers.parseNumber(v, true);
};
module.exports.isValid = function isValid(v) {
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('flex-shrink', parseNumber(v));
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("flex", "");
this._setProperty("flex-shrink", v);
} else {
this._setProperty("flex-shrink", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('flex-shrink');
get() {
return this.getPropertyValue("flex-shrink");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,12 +0,27 @@

'use strict';
"use strict";
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const keywords = ["left", "right", "none", "inline-start", "inline-end"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('float', v);
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("float", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('float');
get() {
return this.getPropertyValue("float");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('flood-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("flood-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('flood-color');
get() {
return this.getPropertyValue("flood-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,43 +0,130 @@

'use strict';
"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;
const parsers = require("../parsers");
const fontStyle = require("./fontStyle");
const fontVariant = require("./fontVariant");
const fontWeight = require("./fontWeight");
const fontSize = require("./fontSize");
const lineHeight = require("./lineHeight");
const fontFamily = require("./fontFamily");
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'),
const shorthandFor = new Map([
["font-style", fontStyle],
["font-variant", fontVariant],
["font-weight", fontWeight],
["font-size", fontSize],
["line-height", lineHeight],
["font-family", fontFamily]
]);
module.exports.parse = function parse(v) {
const keywords = ["caption", "icon", "menu", "message-box", "small-caption", "status-bar"];
const key = parsers.parseKeyword(v, keywords);
if (key) {
return key;
}
const [fontBlock, ...families] = parsers.splitValue(v, {
delimiter: ","
});
let blockA, blockB;
if (fontBlock.includes("/")) {
[blockA, blockB] = parsers.splitValue(fontBlock, {
delimiter: "/"
});
} else {
blockA = fontBlock.trim();
}
const obj = parsers.parseShorthand(blockA, shorthandFor, true);
if (!obj) {
return;
}
const font = {};
const fontFamilies = new Set();
for (const [property, value] of Object.entries(obj)) {
if (property === "font-family") {
if (!blockB) {
fontFamilies.add(value);
}
} else {
font[property] = value;
}
}
// blockB, if matched, includes line-height and first font-family
if (blockB) {
const [lineheight, family] = parsers.splitValue(blockB);
if (lineHeight.isValid(lineheight)) {
font["line-height"] = lineHeight.parse(lineheight);
} else {
return;
}
if (fontFamily.isValid(family)) {
fontFamilies.add(fontFamily.parse(family));
} else {
return;
}
}
for (const family of families) {
if (fontFamily.isValid(family)) {
fontFamilies.add(fontFamily.parse(family));
} else {
return;
}
}
font["font-family"] = [...fontFamilies].join(", ");
return font;
};
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);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
for (const [key] of shorthandFor) {
this._setProperty(key, "");
}
this._setProperty("font", v);
} else {
const obj = module.exports.parse(v);
if (!obj) {
return;
}
const str = new Set();
for (const [key] of shorthandFor) {
const val = obj[key];
if (typeof val === "string") {
this._setProperty(key, val);
if (val && !str.has(val)) {
if (key === "line-height") {
str.add(`/ ${val}`);
} else {
str.add(val);
}
}
}
}
this._setProperty("font", [...str].join(" "));
}
if (valueType(v) === TYPES.KEYWORD && static_fonts.indexOf(v.toLowerCase()) !== -1) {
this._setProperty('font', v);
},
get() {
const val = this.getPropertyValue("font");
if (parsers.hasVarFunc(val)) {
return val;
}
const str = new Set();
for (const [key] of shorthandFor) {
const v = this.getPropertyValue(key);
if (parsers.hasVarFunc(v)) {
return "";
}
if (v && !str.has(v)) {
if (key === "line-height") {
str.add(`/ ${v}`);
} else {
str.add(`${v}`);
}
}
}
return [...str].join(" ");
},
get: shorthandGetter('font', shorthand_for),
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,33 +0,71 @@

'use strict';
"use strict";
var TYPES = require('../parsers').TYPES;
var valueType = require('../parsers').valueType;
const parsers = require("../parsers");
var partsRegEx = /\s*,\s*/;
module.exports.isValid = function isValid(v) {
if (v === '' || v === null) {
return true;
module.exports.parse = function parse(v) {
if (v === "") {
return v;
}
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;
const keywords = ["serif", "sans-serif", "system-ui", "cursive", "fantasy", "monospace"];
const val = parsers.splitValue(v, {
delimiter: ","
});
const font = [];
let valid = false;
for (const i of val) {
const str = parsers.parseString(i);
if (str) {
font.push(str);
valid = true;
continue;
}
const key = parsers.parseKeyword(i, keywords);
if (key) {
font.push(key);
valid = true;
continue;
}
// This implementation does not strictly follow the specification. The spec
// does not require the first letter of the font-family to be capitalized.
// Also, unquoted font-family names are not restricted to ASCII only.
// However, in the real world, the first letter of the ASCII font-family
// names are always capitalized, and unquoted font-family names do not
// contain spaces, e.g. `Times`, and AFAIK, non-ASCII font-family names are
// always quoted even without spaces, e.g. `"メイリオ"`.
// Therefore, it is unlikely that this implementation will cause problems.
// @see https://drafts.csswg.org/css-fonts/#font-family-prop
if (/^\s*(?:[A-Z][A-Za-z\d\s-]+)\s*$/.test(i)) {
font.push(i.trim());
valid = true;
continue;
}
if (!valid) {
return;
}
}
return false;
return font.join(", ");
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('font-family', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("font", "");
this._setProperty("font-family", v);
} else {
this._setProperty("font-family", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('font-family');
get() {
return this.getPropertyValue("font-family");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,38 +0,47 @@

'use strict';
"use strict";
var TYPES = require('../parsers').TYPES;
var valueType = require('../parsers').valueType;
var parseMeasurement = require('../parsers').parseMeasurement;
const parsers = require("../parsers");
var absoluteSizes = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'];
var relativeSizes = ['larger', 'smaller'];
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
const keywords = [
"xx-small",
"x-small",
"small",
"medium",
"large",
"x-large",
"xx-large",
"xxx-large",
"smaller",
"larger"
];
return parsers.parseKeyword(v, keywords);
};
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.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
function parse(v) {
const valueAsString = String(v).toLowerCase();
const optionalArguments = absoluteSizes.concat(relativeSizes);
const isOptionalArgument = optionalArguments.some(
(stringValue) => stringValue.toLowerCase() === valueAsString
);
return isOptionalArgument ? valueAsString : parseMeasurement(v);
}
module.exports.definition = {
set: function (v) {
this._setProperty('font-size', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("font", "");
this._setProperty("font-size", v);
} else {
this._setProperty("font-size", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('font-size');
get() {
return this.getPropertyValue("font-size");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,18 +0,32 @@

'use strict';
"use strict";
var valid_styles = ['normal', 'italic', 'oblique', 'inherit'];
const parsers = require("../parsers");
module.exports.isValid = function (v) {
return valid_styles.indexOf(v.toLowerCase()) !== -1;
module.exports.parse = function parse(v) {
const keywords = ["normal", "italic", "oblique"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('font-style', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("font", "");
this._setProperty("font-style", v);
} else {
this._setProperty("font-style", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('font-style');
get() {
return this.getPropertyValue("font-style");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,18 +0,36 @@

'use strict';
"use strict";
var valid_variants = ['normal', 'small-caps', 'inherit'];
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const num = parsers.parseNumber(v, true);
if (num && parseFloat(num) <= 1000) {
return num;
}
const keywords = ["normal", "none", "small-caps"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
return valid_variants.indexOf(v.toLowerCase()) !== -1;
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('font-variant', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("font", "");
this._setProperty("font-valiant", v);
} else {
this._setProperty("font-variant", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('font-variant');
get() {
return this.getPropertyValue("font-variant");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,33 +0,36 @@

'use strict';
"use strict";
var valid_weights = [
'normal',
'bold',
'bolder',
'lighter',
'100',
'200',
'300',
'400',
'500',
'600',
'700',
'800',
'900',
'inherit',
];
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const num = parsers.parseNumber(v, true);
if (num && parseFloat(num) <= 1000) {
return num;
}
const keywords = ["normal", "bold", "lighter", "bolder"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
return valid_weights.indexOf(v.toLowerCase()) !== -1;
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('font-weight', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("font", "");
this._setProperty("font-weight", v);
} else {
this._setProperty("font-weight", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('font-weight');
get() {
return this.getPropertyValue("font-weight");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,24 +0,31 @@

'use strict';
"use strict";
var parseMeasurement = require('../parsers').parseMeasurement;
const parsers = require("../parsers");
function parse(v) {
if (String(v).toLowerCase() === 'auto') {
return 'auto';
module.exports.parse = function parse(v) {
const dim = parsers.parseMeasurement(v, true);
if (dim) {
return dim;
}
if (String(v).toLowerCase() === 'inherit') {
return 'inherit';
const keywords = ["auto", "min-content", "max-content", "fit-content"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return parseMeasurement(v);
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('height', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("height", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('height');
get() {
return this.getPropertyValue("height");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseMeasurement = require('../parsers').parseInheritingMeasurement;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const dim = parsers.parseMeasurement(v);
if (dim) {
return dim;
}
return parsers.parseKeyword(v, ["auto"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('left', parseMeasurement(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("left", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('left');
get() {
return this.getPropertyValue("left");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('lighting-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("lighting-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('lighting-color');
get() {
return this.getPropertyValue("lighting-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,26 +0,39 @@

'use strict';
"use strict";
var TYPES = require('../parsers').TYPES;
var valueType = require('../parsers').valueType;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseKeyword(v, ["normal"]);
if (val) {
return val;
}
const num = parsers.parseNumber(v, true);
if (num) {
return num;
}
return parsers.parseMeasurement(v, true);
};
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
);
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('line-height', v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("font", "");
this._setProperty("line-height", v);
} else {
this._setProperty("line-height", module.exports.parse(v));
}
},
get: function () {
return this.getPropertyValue('line-height');
get() {
return this.getPropertyValue("line-height");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,73 +0,58 @@

'use strict';
"use strict";
var parsers = require('../parsers.js');
var TYPES = parsers.TYPES;
const parsers = require("../parsers");
var isValid = function (v) {
if (v.toLowerCase() === 'auto') {
return true;
}
var type = parsers.valueType(v);
return (
type === TYPES.NULL_OR_EMPTY_STR ||
type === TYPES.LENGTH ||
type === TYPES.PERCENT ||
type === TYPES.CALC ||
(type === TYPES.INTEGER && (v === '0' || v === 0))
);
};
const positions = ["top", "right", "bottom", "left"];
var parser = function (v) {
var V = v.toLowerCase();
if (V === 'auto') {
return V;
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseMeasurement(v);
return parsers.parseKeyword(v, ["auto"]);
};
var mySetter = parsers.implicitSetter('margin', '', isValid, parser);
var myGlobal = parsers.implicitSetter(
'margin',
'',
function () {
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
},
function (v) {
return v;
}
);
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
if (typeof v === 'number') {
v = String(v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._implicitSetter(
"margin",
"",
"",
module.exports.isValid,
module.exports.parse,
positions
);
this._setProperty("margin", v);
} else {
this._implicitSetter(
"margin",
"",
v,
module.exports.isValid,
module.exports.parse,
positions
);
}
if (v === null) {
v = '';
},
get() {
const val = this._implicitGetter("margin", positions);
if (val === "") {
return this.getPropertyValue("margin");
}
if (typeof v !== 'string') {
return;
if (parsers.hasVarFunc(val)) {
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;
}
return val;
},
get: function () {
return this.getPropertyValue('margin');
},
enumerable: true,
configurable: true,
configurable: true
};
module.exports.isValid = isValid;
module.exports.parser = parser;

@@ -1,13 +0,40 @@

'use strict';
"use strict";
var margin = require('./margin.js');
var parsers = require('../parsers.js');
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v, ["auto"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: parsers.subImplicitSetter('margin', 'bottom', margin.isValid, margin.parser),
get: function () {
return this.getPropertyValue('margin-bottom');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("margin", "");
this._setProperty("margin-bottom", v);
} else {
this._subImplicitSetter("margin", "bottom", v, module.exports.isValid, module.exports.parse, [
"top",
"right",
"bottom",
"left"
]);
}
},
get() {
return this.getPropertyValue("margin-bottom");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,13 +0,40 @@

'use strict';
"use strict";
var margin = require('./margin.js');
var parsers = require('../parsers.js');
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v, ["auto"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: parsers.subImplicitSetter('margin', 'left', margin.isValid, margin.parser),
get: function () {
return this.getPropertyValue('margin-left');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("margin", "");
this._setProperty("margin-left", v);
} else {
this._subImplicitSetter("margin", "left", v, module.exports.isValid, module.exports.parse, [
"top",
"right",
"bottom",
"left"
]);
}
},
get() {
return this.getPropertyValue("margin-left");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,13 +0,40 @@

'use strict';
"use strict";
var margin = require('./margin.js');
var parsers = require('../parsers.js');
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v, ["auto"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: parsers.subImplicitSetter('margin', 'right', margin.isValid, margin.parser),
get: function () {
return this.getPropertyValue('margin-right');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("margin", "");
this._setProperty("margin-right", v);
} else {
this._subImplicitSetter("margin", "right", v, module.exports.isValid, module.exports.parse, [
"top",
"right",
"bottom",
"left"
]);
}
},
get() {
return this.getPropertyValue("margin-right");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,13 +0,40 @@

'use strict';
"use strict";
var margin = require('./margin.js');
var parsers = require('../parsers.js');
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v, ["auto"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: parsers.subImplicitSetter('margin', 'top', margin.isValid, margin.parser),
get: function () {
return this.getPropertyValue('margin-top');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("margin", "");
this._setProperty("margin-top", v);
} else {
this._subImplicitSetter("margin", "top", v, module.exports.isValid, module.exports.parse, [
"top",
"right",
"bottom",
"left"
]);
}
},
get() {
return this.getPropertyValue("margin-top");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,46 @@

'use strict';
"use strict";
var parseNumber = require('../parsers').parseNumber;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
let num = parsers.parseNumber(v);
if (num) {
num = parseFloat(num);
if (num < 0) {
return "0";
} else if (num > 1) {
return "1";
}
return `${num}`;
}
let pct = parsers.parsePercent(v);
if (pct) {
pct = parseFloat(pct);
if (pct < 0) {
return "0%";
} else if (pct > 100) {
return "100%";
}
return `${pct}%`;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('opacity', parseNumber(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("opacity", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('opacity');
get() {
return this.getPropertyValue("opacity");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('outline-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("outline-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('outline-color');
get() {
return this.getPropertyValue("outline-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,66 +0,58 @@

'use strict';
"use strict";
var parsers = require('../parsers.js');
var TYPES = parsers.TYPES;
const parsers = require("../parsers");
var isValid = function (v) {
var type = parsers.valueType(v);
return (
type === TYPES.NULL_OR_EMPTY_STR ||
type === TYPES.LENGTH ||
type === TYPES.PERCENT ||
type === TYPES.CALC ||
(type === TYPES.INTEGER && (v === '0' || v === 0))
);
};
const positions = ["top", "right", "bottom", "left"];
var parser = function (v) {
return parsers.parseMeasurement(v);
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
var mySetter = parsers.implicitSetter('padding', '', isValid, parser);
var myGlobal = parsers.implicitSetter(
'padding',
'',
function () {
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
},
function (v) {
return v;
}
);
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
if (typeof v === 'number') {
v = String(v);
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._implicitSetter(
"padding",
"",
"",
module.exports.isValid,
module.exports.parse,
positions
);
this._setProperty("padding", v);
} else {
this._implicitSetter(
"padding",
"",
v,
module.exports.isValid,
module.exports.parse,
positions
);
}
if (v === null) {
v = '';
},
get() {
const val = this._implicitGetter("padding", positions);
if (val === "") {
return this.getPropertyValue("padding");
}
if (typeof v !== 'string') {
return;
if (parsers.hasVarFunc(val)) {
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;
}
return val;
},
get: function () {
return this.getPropertyValue('padding');
},
enumerable: true,
configurable: true,
configurable: true
};
module.exports.isValid = isValid;
module.exports.parser = parser;

@@ -1,13 +0,42 @@

'use strict';
"use strict";
var padding = require('./padding.js');
var parsers = require('../parsers.js');
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: parsers.subImplicitSetter('padding', 'bottom', padding.isValid, padding.parser),
get: function () {
return this.getPropertyValue('padding-bottom');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("padding", "");
this._setProperty("padding-bottom", v);
} else {
this._subImplicitSetter(
"padding",
"bottom",
v,
module.exports.isValid,
module.exports.parse,
["top", "right", "bottom", "left"]
);
}
},
get() {
return this.getPropertyValue("padding-bottom");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,13 +0,40 @@

'use strict';
"use strict";
var padding = require('./padding.js');
var parsers = require('../parsers.js');
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: parsers.subImplicitSetter('padding', 'left', padding.isValid, padding.parser),
get: function () {
return this.getPropertyValue('padding-left');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("padding", "");
this._setProperty("padding-left", v);
} else {
this._subImplicitSetter("padding", "left", v, module.exports.isValid, module.exports.parse, [
"top",
"right",
"bottom",
"left"
]);
}
},
get() {
return this.getPropertyValue("padding-left");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,13 +0,40 @@

'use strict';
"use strict";
var padding = require('./padding.js');
var parsers = require('../parsers.js');
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: parsers.subImplicitSetter('padding', 'right', padding.isValid, padding.parser),
get: function () {
return this.getPropertyValue('padding-right');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("padding", "");
this._setProperty("padding-right", v);
} else {
this._subImplicitSetter("padding", "right", v, module.exports.isValid, module.exports.parse, [
"top",
"right",
"bottom",
"left"
]);
}
},
get() {
return this.getPropertyValue("padding-right");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,13 +0,40 @@

'use strict';
"use strict";
var padding = require('./padding.js');
var parsers = require('../parsers.js');
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseMeasurement(v, true);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: parsers.subImplicitSetter('padding', 'top', padding.isValid, padding.parser),
get: function () {
return this.getPropertyValue('padding-top');
set(v) {
v = parsers.prepareValue(v, this._global);
if (parsers.hasVarFunc(v)) {
this._setProperty("padding", "");
this._setProperty("padding-top", v);
} else {
this._subImplicitSetter("padding", "top", v, module.exports.isValid, module.exports.parse, [
"top",
"right",
"bottom",
"left"
]);
}
},
get() {
return this.getPropertyValue("padding-top");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseMeasurement = require('../parsers').parseInheritingMeasurement;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const dim = parsers.parseMeasurement(v);
if (dim) {
return dim;
}
return parsers.parseKeyword(v, ["auto"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('right', parseMeasurement(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("right", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('right');
get() {
return this.getPropertyValue("right");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('stop-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("stop-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('stop-color');
get() {
return this.getPropertyValue("stop-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseMeasurement = require('../parsers').parseInheritingMeasurement;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const dim = parsers.parseMeasurement(v);
if (dim) {
return dim;
}
return parsers.parseKeyword(v, ["auto"]);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('top', parseMeasurement(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("top", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('top');
get() {
return this.getPropertyValue("top");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-border-after-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-border-after-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-border-after-color');
get() {
return this.getPropertyValue("-webkit-border-after-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-border-before-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-border-before-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-border-before-color');
get() {
return this.getPropertyValue("-webkit-border-before-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-border-end-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-border-end-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-border-end-color');
get() {
return this.getPropertyValue("-webkit-border-end-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-border-start-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-border-start-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-border-start-color');
get() {
return this.getPropertyValue("-webkit-border-start-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-column-rule-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-column-rule-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-column-rule-color');
get() {
return this.getPropertyValue("-webkit-column-rule-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-tap-highlight-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-tap-highlight-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-tap-highlight-color');
get() {
return this.getPropertyValue("-webkit-tap-highlight-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-text-emphasis-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-text-emphasis-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-text-emphasis-color');
get() {
return this.getPropertyValue("-webkit-text-emphasis-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-text-fill-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-text-fill-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-text-fill-color');
get() {
return this.getPropertyValue("-webkit-text-fill-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,14 +0,30 @@

'use strict';
"use strict";
var parseColor = require('../parsers').parseColor;
const parsers = require("../parsers");
module.exports.parse = function parse(v) {
const val = parsers.parseColor(v);
if (val) {
return val;
}
return parsers.parseKeyword(v);
};
module.exports.isValid = function isValid(v) {
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
return true;
}
return parsers.isValidColor(v);
};
module.exports.definition = {
set: function (v) {
this._setProperty('-webkit-text-stroke-color', parseColor(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("-webkit-text-stroke-color", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('-webkit-text-stroke-color');
get() {
return this.getPropertyValue("-webkit-text-stroke-color");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -1,24 +0,31 @@

'use strict';
"use strict";
var parseMeasurement = require('../parsers').parseMeasurement;
const parsers = require("../parsers");
function parse(v) {
if (String(v).toLowerCase() === 'auto') {
return 'auto';
module.exports.parse = function parse(v) {
const dim = parsers.parseMeasurement(v, true);
if (dim) {
return dim;
}
if (String(v).toLowerCase() === 'inherit') {
return 'inherit';
const keywords = ["auto", "min-content", "max-content", "fit-content"];
return parsers.parseKeyword(v, keywords);
};
module.exports.isValid = function isValid(v) {
if (v === "") {
return true;
}
return parseMeasurement(v);
}
return typeof module.exports.parse(v) === "string";
};
module.exports.definition = {
set: function (v) {
this._setProperty('width', parse(v));
set(v) {
v = parsers.prepareValue(v, this._global);
this._setProperty("width", module.exports.parse(v));
},
get: function () {
return this.getPropertyValue('width');
get() {
return this.getPropertyValue("width");
},
enumerable: true,
configurable: true,
configurable: true
};

@@ -9,3 +9,3 @@ {

],
"version": "4.3.1",
"version": "4.4.0",
"homepage": "https://github.com/jsdom/cssstyle",

@@ -41,3 +41,3 @@ "maintainers": [

"dependencies": {
"@asamuzakjp/css-color": "^3.1.2",
"@asamuzakjp/css-color": "^3.2.0",
"rrweb-cssom": "^0.8.0"

@@ -50,2 +50,3 @@ },

"@babel/types": "^7.26.9",
"@domenic/eslint-config": "^4.0.1",
"eslint": "^9.22.0",

@@ -60,6 +61,6 @@ "eslint-config-prettier": "^10.1.1",

"scripts": {
"download": "node ./scripts/downloadLatestProperties.mjs && eslint lib/allProperties.js --fix",
"download": "node ./scripts/downloadLatestProperties.mjs",
"generate": "run-p generate:*",
"generate:implemented_properties": "node ./scripts/generateImplementedProperties.mjs",
"generate:properties": "node ./scripts/generate_properties.js",
"generate:properties": "node ./scripts/generateProperties.js",
"lint": "npm run generate && eslint --max-warnings 0",

@@ -66,0 +67,0 @@ "lint:fix": "eslint --fix --max-warnings 0",