diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-13 21:34:48 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-13 21:34:48 -0800 |
| commit | 76cb9c2a39d477a64824a985ade40507e3bbade1 (patch) | |
| tree | 41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/cssstyle/lib/properties | |
| parent | 819a39a21ac992b1393244a4c283bbb125208c69 (diff) | |
| download | neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2 neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip | |
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/cssstyle/lib/properties')
77 files changed, 5689 insertions, 0 deletions
diff --git a/vanilla/node_modules/cssstyle/lib/properties/background.js b/vanilla/node_modules/cssstyle/lib/properties/background.js new file mode 100644 index 0000000..cf4acb4 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/background.js @@ -0,0 +1,406 @@ +"use strict"; + +const parsers = require("../parsers"); +const backgroundImage = require("./backgroundImage"); +const backgroundPosition = require("./backgroundPosition"); +const backgroundSize = require("./backgroundSize"); +const backgroundRepeat = require("./backgroundRepeat"); +const backgroundOrigin = require("./backgroundOrigin"); +const backgroundClip = require("./backgroundClip"); +const backgroundAttachment = require("./backgroundAttachment"); +const backgroundColor = require("./backgroundColor"); + +const property = "background"; + +module.exports.initialValues = new Map([ + [backgroundImage.property, "none"], + [backgroundPosition.property, "0% 0%"], + [backgroundSize.property, "auto"], + [backgroundRepeat.property, "repeat"], + [backgroundOrigin.property, "padding-box"], + [backgroundClip.property, "border-box"], + [backgroundAttachment.property, "scroll"], + [backgroundColor.property, "transparent"] +]); + +module.exports.shorthandFor = new Map([ + [backgroundImage.property, backgroundImage], + [backgroundPosition.property, backgroundPosition], + [backgroundSize.property, backgroundSize], + [backgroundRepeat.property, backgroundRepeat], + [backgroundOrigin.property, backgroundOrigin], + [backgroundClip.property, backgroundClip], + [backgroundAttachment.property, backgroundAttachment], + [backgroundColor.property, backgroundColor] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } else if (parsers.hasCalcFunc(v)) { + v = parsers.resolveCalc(v); + } + if (!parsers.isValidPropertyValue(property, v)) { + return; + } + const values = parsers.splitValue(v, { + delimiter: "," + }); + const bgValues = []; + const l = values.length; + for (let i = 0; i < l; i++) { + let bg = { + [backgroundImage.property]: module.exports.initialValues.get(backgroundImage.property), + [backgroundPosition.property]: module.exports.initialValues.get(backgroundPosition.property), + [backgroundSize.property]: module.exports.initialValues.get(backgroundSize.property), + [backgroundRepeat.property]: module.exports.initialValues.get(backgroundRepeat.property), + [backgroundOrigin.property]: module.exports.initialValues.get(backgroundOrigin.property), + [backgroundClip.property]: module.exports.initialValues.get(backgroundClip.property), + [backgroundAttachment.property]: module.exports.initialValues.get( + backgroundAttachment.property + ), + [backgroundColor.property]: module.exports.initialValues.get(backgroundColor.property) + }; + if (l > 1 && i !== l - 1) { + bg = { + [backgroundImage.property]: module.exports.initialValues.get(backgroundImage.property), + [backgroundPosition.property]: module.exports.initialValues.get( + backgroundPosition.property + ), + [backgroundSize.property]: module.exports.initialValues.get(backgroundSize.property), + [backgroundRepeat.property]: module.exports.initialValues.get(backgroundRepeat.property), + [backgroundOrigin.property]: module.exports.initialValues.get(backgroundOrigin.property), + [backgroundClip.property]: module.exports.initialValues.get(backgroundClip.property), + [backgroundAttachment.property]: module.exports.initialValues.get( + backgroundAttachment.property + ) + }; + } + const bgPosition = []; + const bgSize = []; + const bgRepeat = []; + const bgBox = []; + const bgParts = parsers.splitValue(values[i], { + delimiter: "/" + }); + if (!bgParts.length || bgParts.length > 2) { + return; + } + const [bgPart1, bgPart2 = ""] = bgParts; + const parts1 = parsers.splitValue(bgPart1); + for (const part of parts1) { + let partValid = false; + for (const [longhand, value] of module.exports.shorthandFor) { + if (parsers.isValidPropertyValue(longhand, part)) { + partValid = true; + switch (longhand) { + case backgroundClip.property: + case backgroundOrigin.property: { + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bgBox.push(parsedValue); + } + break; + } + case backgroundColor.property: { + if (i !== values.length - 1) { + return; + } + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bg[longhand] = parsedValue; + } + break; + } + case backgroundPosition.property: { + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bgPosition.push(parsedValue); + } + break; + } + case backgroundRepeat.property: { + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bgRepeat.push(parsedValue); + } + break; + } + case backgroundSize.property: { + break; + } + default: { + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bg[longhand] = parsedValue; + } + } + } + } + } + if (!partValid) { + return; + } + } + if (bgPart2) { + const parts2 = parsers.splitValue(bgPart2); + for (const part of parts2) { + let partValid = false; + for (const [longhand, value] of module.exports.shorthandFor) { + if (parsers.isValidPropertyValue(longhand, part)) { + partValid = true; + switch (longhand) { + case backgroundClip.property: + case backgroundOrigin.property: { + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bgBox.push(parsedValue); + } + break; + } + case backgroundColor.property: { + if (i !== l - 1) { + return; + } + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bg[longhand] = parsedValue; + } + break; + } + case backgroundPosition.property: { + break; + } + case backgroundRepeat.property: { + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bgRepeat.push(parsedValue); + } + break; + } + case backgroundSize.property: { + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bgSize.push(parsedValue); + } + break; + } + default: { + const parsedValue = value.parse(part, { globalObject }); + if (parsedValue) { + bg[longhand] = parsedValue; + } + } + } + } + } + if (!partValid) { + return; + } + } + } + if (bgPosition.length) { + const { parse: parser } = module.exports.shorthandFor.get(backgroundPosition.property); + const value = parser(bgPosition.join(" "), { globalObject }); + if (value) { + bg[backgroundPosition.property] = value; + } + } + if (bgSize.length) { + const { parse: parser } = module.exports.shorthandFor.get(backgroundSize.property); + const value = parser(bgSize.join(" "), { globalObject }); + if (value) { + bg[backgroundSize.property] = value; + } + } + if (bgRepeat.length) { + const { parse: parser } = module.exports.shorthandFor.get(backgroundRepeat.property); + const value = parser(bgRepeat.join(" "), { globalObject }); + if (value) { + bg[backgroundRepeat.property] = value; + } + } + if (bgBox.length) { + switch (bgBox.length) { + case 1: { + const [value] = bgBox; + bg[backgroundOrigin.property] = value; + bg[backgroundClip.property] = value; + break; + } + case 2: { + const [value1, value2] = bgBox; + bg[backgroundOrigin.property] = value1; + bg[backgroundClip.property] = value2; + break; + } + default: { + return; + } + } + } + bgValues.push(bg); + } + return bgValues; +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (v === "" || parsers.hasVarFunc(v)) { + for (const [key] of module.exports.shorthandFor) { + this._setProperty(key, ""); + } + this._setProperty(property, v); + } else { + const bgValues = module.exports.parse(v, { + globalObject: this._global + }); + if (!Array.isArray(bgValues)) { + return; + } + const bgMap = new Map([ + [backgroundImage.property, []], + [backgroundPosition.property, []], + [backgroundSize.property, []], + [backgroundRepeat.property, []], + [backgroundOrigin.property, []], + [backgroundClip.property, []], + [backgroundAttachment.property, []], + [backgroundColor.property, []] + ]); + const backgrounds = []; + for (const bgValue of bgValues) { + const bg = []; + for (const [longhand, value] of Object.entries(bgValue)) { + if (value) { + const arr = bgMap.get(longhand); + arr.push(value); + bgMap.set(longhand, arr); + if (value !== module.exports.initialValues.get(longhand)) { + if (longhand === backgroundSize.property) { + bg.push(`/ ${value}`); + } else { + bg.push(value); + } + } else if (longhand === backgroundImage.property) { + if (v === "none") { + bg.push(value); + } + } else if (longhand === backgroundColor.property) { + if (v === "transparent") { + bg.push(value); + } + } + } + } + backgrounds.push(bg.join(" ")); + } + const priority = this._priorities.get(property) ?? ""; + for (const [longhand, value] of bgMap) { + this._setProperty(longhand, value.join(", "), priority); + } + this._setProperty(property, backgrounds.join(", "), priority); + } + }, + get() { + const v = this.getPropertyValue(property); + if (parsers.hasVarFunc(v)) { + return v; + } + const bgMap = new Map(); + let l = 0; + for (const [longhand] of module.exports.shorthandFor) { + const val = this.getPropertyValue(longhand); + if (longhand === backgroundImage.property) { + if ( + val === "none" && + v === "none" && + this.getPropertyValue(backgroundColor.property) === "transparent" + ) { + return val; + } + if (val !== module.exports.initialValues.get(longhand)) { + const imgValues = parsers.splitValue(val, { + delimiter: "," + }); + l = imgValues.length; + bgMap.set(longhand, imgValues); + } + } else if (longhand === backgroundColor.property) { + if (val !== module.exports.initialValues.get(longhand) || v.includes(val)) { + bgMap.set(longhand, [val]); + } + } else if (val !== module.exports.initialValues.get(longhand)) { + bgMap.set( + longhand, + parsers.splitValue(val, { + delimiter: "," + }) + ); + } + } + if (l === 0) { + const bgColArr = bgMap.get(backgroundColor.property); + const background = bgColArr ? bgColArr[0] : null; + if (background) { + return background; + } + return ""; + } + const bgValues = []; + for (let i = 0; i < l; i++) { + bgValues[i] = []; + } + for (const [longhand, values] of bgMap) { + for (let i = 0; i < l; i++) { + switch (longhand) { + case backgroundColor.property: { + if (i === l - 1) { + const value = values[0]; + if (parsers.hasVarFunc(value)) { + return ""; + } + if (value && value !== module.exports.initialValues.get(longhand)) { + const bgValue = bgValues[i]; + bgValue.push(value); + } + } + break; + } + case backgroundSize.property: { + const value = values[i]; + if (parsers.hasVarFunc(value)) { + return ""; + } + if (value && value !== module.exports.initialValues.get(longhand)) { + const bgValue = bgValues[i]; + bgValue.push(`/ ${value}`); + } + break; + } + default: { + const value = values[i]; + if (parsers.hasVarFunc(value)) { + return ""; + } + if (value && value !== module.exports.initialValues.get(longhand)) { + const bgValue = bgValues[i]; + bgValue.push(value); + } + } + } + } + } + const backgrounds = []; + for (const bgValue of bgValues) { + backgrounds.push(bgValue.join(" ")); + } + return backgrounds.join(", "); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/backgroundAttachment.js b/vanilla/node_modules/cssstyle/lib/properties/backgroundAttachment.js new file mode 100644 index 0000000..32b3aff --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/backgroundAttachment.js @@ -0,0 +1,61 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "background-attachment"; +const shorthand = "background"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v, { delimiter: "," }); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveKeywordValue(value); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } else if (typeof value === "string") { + parsedValues.push(value); + } + } + if (parsedValues.length) { + return parsedValues.join(", "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/backgroundClip.js b/vanilla/node_modules/cssstyle/lib/properties/backgroundClip.js new file mode 100644 index 0000000..80407bc --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/backgroundClip.js @@ -0,0 +1,61 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "background-clip"; +const shorthand = "background"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v, { delimiter: "," }); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveKeywordValue(value); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } else if (typeof value === "string") { + parsedValues.push(value); + } + } + if (parsedValues.length) { + return parsedValues.join(", "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/backgroundColor.js b/vanilla/node_modules/cssstyle/lib/properties/backgroundColor.js new file mode 100644 index 0000000..7d3bf99 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/backgroundColor.js @@ -0,0 +1,50 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "background-color"; +const shorthand = "background"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/backgroundImage.js b/vanilla/node_modules/cssstyle/lib/properties/backgroundImage.js new file mode 100644 index 0000000..8959685 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/backgroundImage.js @@ -0,0 +1,63 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "background-image"; +const shorthand = "background"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v, { delimiter: "," }); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveGradientUrlValue(value); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } else if (typeof value === "string") { + parsedValues.push(value); + } else { + return; + } + } + if (parsedValues.length) { + return parsedValues.join(", "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/backgroundOrigin.js b/vanilla/node_modules/cssstyle/lib/properties/backgroundOrigin.js new file mode 100644 index 0000000..a1fe9ac --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/backgroundOrigin.js @@ -0,0 +1,61 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "background-origin"; +const shorthand = "background"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v, { delimiter: "," }); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveKeywordValue(value); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } else if (typeof value === "string") { + parsedValues.push(value); + } + } + if (parsedValues.length) { + return parsedValues.join(", "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/backgroundPosition.js b/vanilla/node_modules/cssstyle/lib/properties/backgroundPosition.js new file mode 100644 index 0000000..23c6c68 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/backgroundPosition.js @@ -0,0 +1,204 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "background-position"; +const shorthand = "background"; +const keyX = ["left", "right"]; +const keyY = ["top", "bottom"]; +const keywordsX = ["center", ...keyX]; +const keywordsY = ["center", ...keyY]; +const keywords = ["center", ...keyX, ...keyY]; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const { AST_TYPES } = parsers; + const values = parsers.splitValue(v, { + delimiter: "," + }); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length) { + const [part1, part2, part3, part4] = value; + let parsedValue = ""; + switch (value.length) { + case 1: { + const val1 = + part1.type === AST_TYPES.IDENTIFIER + ? part1.name + : parsers.resolveNumericValue([part1], { type: "length" }); + if (val1) { + if (val1 === "center") { + parsedValue = `${val1} ${val1}`; + } else if (val1 === "top" || val1 === "bottom") { + parsedValue = `center ${val1}`; + } else { + parsedValue = `${val1} center`; + } + } + break; + } + case 2: { + const val1 = + part1.type === AST_TYPES.IDENTIFIER + ? part1.name + : parsers.resolveNumericValue([part1], { type: "length" }); + const val2 = + part2.type === AST_TYPES.IDENTIFIER + ? part2.name + : parsers.resolveNumericValue([part2], { type: "length" }); + if (val1 && val2) { + if (keywordsX.includes(val1) && keywordsY.includes(val2)) { + parsedValue = `${val1} ${val2}`; + } else if (keywordsY.includes(val1) && keywordsX.includes(val2)) { + parsedValue = `${val2} ${val1}`; + } else if (keywordsX.includes(val1)) { + if (val2 === "center" || !keywordsX.includes(val2)) { + parsedValue = `${val1} ${val2}`; + } + } else if (keywordsY.includes(val2)) { + if (!keywordsY.includes(val1)) { + parsedValue = `${val1} ${val2}`; + } + } else if (!keywordsY.includes(val1) && !keywordsX.includes(val2)) { + parsedValue = `${val1} ${val2}`; + } + } + break; + } + case 3: { + const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name; + const val2 = + part2.type === AST_TYPES.IDENTIFIER + ? part2.name + : parsers.resolveNumericValue([part2], { type: "length" }); + const val3 = + part3.type === AST_TYPES.IDENTIFIER + ? part3.name + : parsers.resolveNumericValue([part3], { type: "length" }); + if (val1 && val2 && val3) { + let posX = ""; + let offX = ""; + let posY = ""; + let offY = ""; + if (keywordsX.includes(val1)) { + if (keyY.includes(val2)) { + if (!keywords.includes(val3)) { + posX = val1; + posY = val2; + offY = val3; + } + } else if (keyY.includes(val3)) { + if (!keywords.includes(val2)) { + posX = val1; + offX = val2; + posY = val3; + } + } + } else if (keywordsY.includes(val1)) { + if (keyX.includes(val2)) { + if (!keywords.includes(val3)) { + posX = val2; + offX = val3; + posY = val1; + } + } else if (keyX.includes(val3)) { + if (!keywords.includes(val2)) { + posX = val3; + posY = val1; + offY = val2; + } + } + } + if (posX && posY) { + if (offX) { + parsedValue = `${posX} ${offX} ${posY}`; + } else if (offY) { + parsedValue = `${posX} ${posY} ${offY}`; + } + } + } + break; + } + case 4: { + const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name; + const val2 = parsers.resolveNumericValue([part2], { type: "length" }); + const val3 = part3.type === AST_TYPES.IDENTIFIER && part3.name; + const val4 = parsers.resolveNumericValue([part4], { type: "length" }); + if (val1 && val2 && val3 && val4) { + let posX = ""; + let offX = ""; + let posY = ""; + let offY = ""; + if (keywordsX.includes(val1) && keyY.includes(val3)) { + posX = val1; + offX = val2; + posY = val3; + offY = val4; + } else if (keyX.includes(val1) && keywordsY.includes(val3)) { + posX = val1; + offX = val2; + posY = val3; + offY = val4; + } else if (keyY.includes(val1) && keywordsX.includes(val3)) { + posX = val3; + offX = val4; + posY = val1; + offY = val2; + } + if (posX && offX && posY && offY) { + parsedValue = `${posX} ${offX} ${posY} ${offY}`; + } + } + break; + } + default: + } + if (parsedValue) { + parsedValues.push(parsedValue); + } else { + return; + } + } else if (typeof value === "string") { + parsedValues.push(value); + } + } + if (parsedValues.length) { + return parsedValues.join(", "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/backgroundRepeat.js b/vanilla/node_modules/cssstyle/lib/properties/backgroundRepeat.js new file mode 100644 index 0000000..6bb9ddd --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/backgroundRepeat.js @@ -0,0 +1,93 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "background-repeat"; +const shorthand = "background"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const { AST_TYPES } = parsers; + const values = parsers.splitValue(v, { + delimiter: "," + }); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length) { + let parsedValue = ""; + switch (value.length) { + case 1: { + const [part1] = value; + const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name; + if (val1) { + parsedValue = val1; + } + break; + } + case 2: { + const [part1, part2] = value; + const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name; + const val2 = part2.type === AST_TYPES.IDENTIFIER && part2.name; + if (val1 && val2) { + if (val1 === "repeat" && val2 === "no-repeat") { + parsedValue = "repeat-x"; + } else if (val1 === "no-repeat" && val2 === "repeat") { + parsedValue = "repeat-y"; + } else if (val1 === val2) { + parsedValue = val1; + } else { + parsedValue = `${val1} ${val2}`; + } + } + break; + } + default: + } + if (parsedValue) { + parsedValues.push(parsedValue); + } else { + return; + } + } else if (typeof value === "string") { + parsedValues.push(value); + } + } + if (parsedValues.length) { + return parsedValues.join(", "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/backgroundSize.js b/vanilla/node_modules/cssstyle/lib/properties/backgroundSize.js new file mode 100644 index 0000000..be31044 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/backgroundSize.js @@ -0,0 +1,126 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "background-size"; +const shorthand = "background"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const { AST_TYPES } = parsers; + const values = parsers.splitValue(v, { + delimiter: "," + }); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length) { + if (value.length === 1) { + const [{ isNumber, name, type, value: itemValue }] = value; + switch (type) { + case AST_TYPES.CALC: { + if (isNumber) { + return; + } + parsedValues.push(`${name}(${itemValue})`); + break; + } + case AST_TYPES.GLOBAL_KEYWORD: + case AST_TYPES.IDENTIFIER: { + parsedValues.push(name); + break; + } + default: { + const parsedValue = parsers.resolveNumericValue(value, { + type: "length" + }); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } + } + } else { + const [val1, val2] = value; + const parts = []; + if (val1.type === AST_TYPES.CALC && !val1.isNumber) { + parts.push(`${val1.name}(${val1.value})`); + } else if (val1.type === AST_TYPES.IDENTIFIER) { + parts.push(val1.name); + } else if (val1.type === AST_TYPES.DIMENSION) { + parts.push(`${val1.value}${val1.unit}`); + } else if (val1.type === AST_TYPES.PERCENTAGE) { + parts.push(`${val1.value}%`); + } else { + return; + } + switch (val2.type) { + case AST_TYPES.CALC: { + if (val2.isNumber) { + return; + } + parts.push(`${val2.name}(${val2.value})`); + break; + } + case AST_TYPES.DIMENSION: { + parts.push(`${val2.value}${val2.unit}`); + break; + } + case AST_TYPES.IDENTIFIER: { + if (val2.name !== "auto") { + parts.push(val2.name); + } + break; + } + case AST_TYPES.PERCENTAGE: { + parts.push(`${val2.value}%`); + break; + } + default: { + return; + } + } + parsedValues.push(parts.join(" ")); + } + } else if (typeof value === "string") { + parsedValues.push(value); + } + } + if (parsedValues.length) { + return parsedValues.join(", "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/border.js b/vanilla/node_modules/cssstyle/lib/properties/border.js new file mode 100644 index 0000000..889bd5a --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/border.js @@ -0,0 +1,107 @@ +"use strict"; + +const parsers = require("../parsers"); +const borderWidth = require("./borderWidth"); +const borderStyle = require("./borderStyle"); +const borderColor = require("./borderColor"); +const borderTop = require("./borderTop"); +const borderRight = require("./borderRight"); +const borderBottom = require("./borderBottom"); +const borderLeft = require("./borderLeft"); + +const property = "border"; + +const subProps = { + width: borderWidth.property, + style: borderStyle.property, + color: borderColor.property +}; + +module.exports.initialValues = new Map([ + [borderWidth.property, "medium"], + [borderStyle.property, "none"], + [borderColor.property, "currentcolor"] +]); + +module.exports.shorthandFor = new Map([ + [borderWidth.property, borderWidth], + [borderStyle.property, borderStyle], + [borderColor.property, borderColor] +]); + +module.exports.positionShorthandFor = new Map([ + [borderTop.property, borderTop], + [borderRight.property, borderRight], + [borderBottom.property, borderBottom], + [borderLeft.property, borderLeft] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "" || parsers.hasVarFunc(v)) { + return v; + } + const values = parsers.splitValue(v); + const parsedValues = new Map(); + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues); + if (typeof parsedValue === "string") { + return parsedValue; + } else if (Array.isArray(parsedValue)) { + const [key, resolvedVal] = parsedValue; + parsedValues.set(key, resolvedVal); + } else { + return; + } + } else { + return; + } + } + if (parsedValues.size) { + const keys = module.exports.shorthandFor.keys(); + const obj = { + [borderWidth.property]: "medium" + }; + for (const key of keys) { + if (parsedValues.has(key)) { + const parsedValue = parsedValues.get(key); + if (parsedValue !== module.exports.initialValues.get(key)) { + obj[key] = parsedValues.get(key); + if (obj[borderWidth.property] && obj[borderWidth.property] === "medium") { + delete obj[borderWidth.property]; + } + } + } + } + return obj; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (val || typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderBottom.js b/vanilla/node_modules/cssstyle/lib/properties/borderBottom.js new file mode 100644 index 0000000..7cb2892 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderBottom.js @@ -0,0 +1,100 @@ +"use strict"; + +const parsers = require("../parsers"); +const borderBottomWidth = require("./borderBottomWidth"); +const borderBottomStyle = require("./borderBottomStyle"); +const borderBottomColor = require("./borderBottomColor"); + +const property = "border-bottom"; +const shorthand = "border"; + +const subProps = { + width: borderBottomWidth.property, + style: borderBottomStyle.property, + color: borderBottomColor.property +}; + +module.exports.initialValues = new Map([ + [borderBottomWidth.property, "medium"], + [borderBottomStyle.property, "none"], + [borderBottomColor.property, "currentcolor"] +]); + +module.exports.shorthandFor = new Map([ + [borderBottomWidth.property, borderBottomWidth], + [borderBottomStyle.property, borderBottomStyle], + [borderBottomColor.property, borderBottomColor] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v); + const parsedValues = new Map(); + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues); + if (typeof parsedValue === "string") { + return parsedValue; + } else if (Array.isArray(parsedValue)) { + const [key, resolvedVal] = parsedValue; + parsedValues.set(key, resolvedVal); + } else { + return; + } + } else { + return; + } + } + if (parsedValues.size) { + const keys = module.exports.shorthandFor.keys(); + const obj = { + [borderBottomWidth.property]: "medium" + }; + for (const key of keys) { + if (parsedValues.has(key)) { + const parsedValue = parsedValues.get(key); + if (parsedValue !== module.exports.initialValues.get(key)) { + obj[key] = parsedValues.get(key); + if (obj[borderBottomWidth.property] && obj[borderBottomWidth.property] === "medium") { + delete obj[borderBottomWidth.property]; + } + } + } + } + return obj; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (val || typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderBottomColor.js b/vanilla/node_modules/cssstyle/lib/properties/borderBottomColor.js new file mode 100644 index 0000000..b458fd4 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderBottomColor.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-bottom-color"; +const lineShorthand = "border-color"; +const positionShorthand = "border-bottom"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderBottomStyle.js b/vanilla/node_modules/cssstyle/lib/properties/borderBottomStyle.js new file mode 100644 index 0000000..b54b6a9 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderBottomStyle.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-bottom-style"; +const lineShorthand = "border-style"; +const positionShorthand = "border-bottom"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveKeywordValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderBottomWidth.js b/vanilla/node_modules/cssstyle/lib/properties/borderBottomWidth.js new file mode 100644 index 0000000..3200365 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderBottomWidth.js @@ -0,0 +1,57 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-bottom-width"; +const lineShorthand = "border-width"; +const positionShorthand = "border-bottom"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderCollapse.js b/vanilla/node_modules/cssstyle/lib/properties/borderCollapse.js new file mode 100644 index 0000000..f77c445 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderCollapse.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-collapse"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveKeywordValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderColor.js b/vanilla/node_modules/cssstyle/lib/properties/borderColor.js new file mode 100644 index 0000000..232d34c --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderColor.js @@ -0,0 +1,110 @@ +"use strict"; + +const parsers = require("../parsers"); +const borderTopColor = require("./borderTopColor"); +const borderRightColor = require("./borderRightColor"); +const borderBottomColor = require("./borderBottomColor"); +const borderLeftColor = require("./borderLeftColor"); + +const property = "border-color"; +const shorthand = "border"; + +module.exports.shorthandFor = new Map([ + [borderTopColor.property, borderTopColor], + [borderRightColor.property, borderRightColor], + [borderBottomColor.property, borderBottomColor], + [borderLeftColor.property, borderLeftColor] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + const parsedValues = []; + if (Array.isArray(values) && values.length) { + if (values.length > 4) { + return; + } + for (const value of values) { + const parsedValue = parsers.resolveColorValue([value], { + length: values.length + }); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } + } else if (typeof values === "string") { + parsedValues.push(values); + } + if (parsedValues.length) { + switch (parsedValues.length) { + case 1: { + return parsedValues; + } + case 2: { + const [val1, val2] = parsedValues; + if (val1 === val2) { + return [val1]; + } + return parsedValues; + } + case 3: { + const [val1, val2, val3] = parsedValues; + if (val1 === val3) { + if (val1 === val2) { + return [val1]; + } + return [val1, val2]; + } + return parsedValues; + } + case 4: { + const [val1, val2, val3, val4] = parsedValues; + if (val2 === val4) { + if (val1 === val3) { + if (val1 === val2) { + return [val1]; + } + return [val1, val2]; + } + return [val1, val2, val3]; + } + return parsedValues; + } + default: + } + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (Array.isArray(val) || typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderLeft.js b/vanilla/node_modules/cssstyle/lib/properties/borderLeft.js new file mode 100644 index 0000000..7c40f58 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderLeft.js @@ -0,0 +1,100 @@ +"use strict"; + +const parsers = require("../parsers"); +const borderLeftWidth = require("./borderLeftWidth"); +const borderLeftStyle = require("./borderLeftStyle"); +const borderLeftColor = require("./borderLeftColor"); + +const property = "border-left"; +const shorthand = "border"; + +const subProps = { + width: borderLeftWidth.property, + style: borderLeftStyle.property, + color: borderLeftColor.property +}; + +module.exports.initialValues = new Map([ + [borderLeftWidth.property, "medium"], + [borderLeftStyle.property, "none"], + [borderLeftColor.property, "currentcolor"] +]); + +module.exports.shorthandFor = new Map([ + [borderLeftWidth.property, borderLeftWidth], + [borderLeftStyle.property, borderLeftStyle], + [borderLeftColor.property, borderLeftColor] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v); + const parsedValues = new Map(); + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues); + if (typeof parsedValue === "string") { + return parsedValue; + } else if (Array.isArray(parsedValue)) { + const [key, resolvedVal] = parsedValue; + parsedValues.set(key, resolvedVal); + } else { + return; + } + } else { + return; + } + } + if (parsedValues.size) { + const keys = module.exports.shorthandFor.keys(); + const obj = { + [borderLeftWidth.property]: "medium" + }; + for (const key of keys) { + if (parsedValues.has(key)) { + const parsedValue = parsedValues.get(key); + if (parsedValue !== module.exports.initialValues.get(key)) { + obj[key] = parsedValues.get(key); + if (obj[borderLeftWidth.property] && obj[borderLeftWidth.property] === "medium") { + delete obj[borderLeftWidth.property]; + } + } + } + } + return obj; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (val || typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderLeftColor.js b/vanilla/node_modules/cssstyle/lib/properties/borderLeftColor.js new file mode 100644 index 0000000..7cb630e --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderLeftColor.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-left-color"; +const lineShorthand = "border-color"; +const positionShorthand = "border-left"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderLeftStyle.js b/vanilla/node_modules/cssstyle/lib/properties/borderLeftStyle.js new file mode 100644 index 0000000..8fa5761 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderLeftStyle.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-left-style"; +const lineShorthand = "border-style"; +const positionShorthand = "border-left"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveKeywordValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderLeftWidth.js b/vanilla/node_modules/cssstyle/lib/properties/borderLeftWidth.js new file mode 100644 index 0000000..74dd03f --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderLeftWidth.js @@ -0,0 +1,57 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-left-width"; +const lineShorthand = "border-width"; +const positionShorthand = "border-left"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderRight.js b/vanilla/node_modules/cssstyle/lib/properties/borderRight.js new file mode 100644 index 0000000..43c2878 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderRight.js @@ -0,0 +1,100 @@ +"use strict"; + +const parsers = require("../parsers"); +const borderRightWidth = require("./borderRightWidth"); +const borderRightStyle = require("./borderRightStyle"); +const borderRightColor = require("./borderRightColor"); + +const property = "border-right"; +const shorthand = "border"; + +const subProps = { + width: borderRightWidth.property, + style: borderRightStyle.property, + color: borderRightColor.property +}; + +module.exports.initialValues = new Map([ + [borderRightWidth.property, "medium"], + [borderRightStyle.property, "none"], + [borderRightColor.property, "currentcolor"] +]); + +module.exports.shorthandFor = new Map([ + [borderRightWidth.property, borderRightWidth], + [borderRightStyle.property, borderRightStyle], + [borderRightColor.property, borderRightColor] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v); + const parsedValues = new Map(); + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues); + if (typeof parsedValue === "string") { + return parsedValue; + } else if (Array.isArray(parsedValue)) { + const [key, resolvedVal] = parsedValue; + parsedValues.set(key, resolvedVal); + } else { + return; + } + } else { + return; + } + } + if (parsedValues.size) { + const keys = module.exports.shorthandFor.keys(); + const obj = { + [borderRightWidth.property]: "medium" + }; + for (const key of keys) { + if (parsedValues.has(key)) { + const parsedValue = parsedValues.get(key); + if (parsedValue !== module.exports.initialValues.get(key)) { + obj[key] = parsedValues.get(key); + if (obj[borderRightWidth.property] && obj[borderRightWidth.property] === "medium") { + delete obj[borderRightWidth.property]; + } + } + } + } + return obj; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (val || typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderRightColor.js b/vanilla/node_modules/cssstyle/lib/properties/borderRightColor.js new file mode 100644 index 0000000..9071c50 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderRightColor.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-right-color"; +const lineShorthand = "border-color"; +const positionShorthand = "border-right"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderRightStyle.js b/vanilla/node_modules/cssstyle/lib/properties/borderRightStyle.js new file mode 100644 index 0000000..09ffe48 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderRightStyle.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-right-style"; +const lineShorthand = "border-style"; +const positionShorthand = "border-right"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveKeywordValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderRightWidth.js b/vanilla/node_modules/cssstyle/lib/properties/borderRightWidth.js new file mode 100644 index 0000000..b56ab28 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderRightWidth.js @@ -0,0 +1,57 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-right-width"; +const lineShorthand = "border-width"; +const positionShorthand = "border-right"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderSpacing.js b/vanilla/node_modules/cssstyle/lib/properties/borderSpacing.js new file mode 100644 index 0000000..3bba0be --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderSpacing.js @@ -0,0 +1,65 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-spacing"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length) { + switch (value.length) { + case 1: { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } + case 2: { + const [part1, part2] = value; + const val1 = parsers.resolveNumericValue([part1], { + type: "length" + }); + const val2 = parsers.resolveNumericValue([part2], { + type: "length" + }); + if (val1 && val2) { + return `${val1} ${val2}`; + } + break; + } + default: + } + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderStyle.js b/vanilla/node_modules/cssstyle/lib/properties/borderStyle.js new file mode 100644 index 0000000..2cf8836 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderStyle.js @@ -0,0 +1,110 @@ +"use strict"; + +const parsers = require("../parsers"); +const borderTopStyle = require("./borderTopStyle"); +const borderRightStyle = require("./borderRightStyle"); +const borderBottomStyle = require("./borderBottomStyle"); +const borderLeftStyle = require("./borderLeftStyle"); + +const property = "border-style"; +const shorthand = "border"; + +module.exports.shorthandFor = new Map([ + [borderTopStyle.property, borderTopStyle], + [borderRightStyle.property, borderRightStyle], + [borderBottomStyle.property, borderBottomStyle], + [borderLeftStyle.property, borderLeftStyle] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + const parsedValues = []; + if (Array.isArray(values) && values.length) { + if (values.length > 4) { + return; + } + for (const value of values) { + const parsedValue = parsers.resolveKeywordValue([value], { + length: values.length + }); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } + } else if (typeof values === "string") { + parsedValues.push(values); + } + if (parsedValues.length) { + switch (parsedValues.length) { + case 1: { + return parsedValues; + } + case 2: { + const [val1, val2] = parsedValues; + if (val1 === val2) { + return [val1]; + } + return parsedValues; + } + case 3: { + const [val1, val2, val3] = parsedValues; + if (val1 === val3) { + if (val1 === val2) { + return [val1]; + } + return [val1, val2]; + } + return parsedValues; + } + case 4: { + const [val1, val2, val3, val4] = parsedValues; + if (val2 === val4) { + if (val1 === val3) { + if (val1 === val2) { + return [val1]; + } + return [val1, val2]; + } + return [val1, val2, val3]; + } + return parsedValues; + } + default: + } + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (Array.isArray(val) || typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderTop.js b/vanilla/node_modules/cssstyle/lib/properties/borderTop.js new file mode 100644 index 0000000..29f649d --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderTop.js @@ -0,0 +1,100 @@ +"use strict"; + +const parsers = require("../parsers"); +const borderTopWidth = require("./borderTopWidth"); +const borderTopStyle = require("./borderTopStyle"); +const borderTopColor = require("./borderTopColor"); + +const property = "border-top"; +const shorthand = "border"; + +const subProps = { + width: borderTopWidth.property, + style: borderTopStyle.property, + color: borderTopColor.property +}; + +module.exports.initialValues = new Map([ + [borderTopWidth.property, "medium"], + [borderTopStyle.property, "none"], + [borderTopColor.property, "currentcolor"] +]); + +module.exports.shorthandFor = new Map([ + [borderTopWidth.property, borderTopWidth], + [borderTopStyle.property, borderTopStyle], + [borderTopColor.property, borderTopColor] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v); + const parsedValues = new Map(); + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues); + if (typeof parsedValue === "string") { + return parsedValue; + } else if (Array.isArray(parsedValue)) { + const [key, resolvedVal] = parsedValue; + parsedValues.set(key, resolvedVal); + } else { + return; + } + } else { + return; + } + } + if (parsedValues.size) { + const keys = module.exports.shorthandFor.keys(); + const obj = { + [borderTopWidth.property]: "medium" + }; + for (const key of keys) { + if (parsedValues.has(key)) { + const parsedValue = parsedValues.get(key); + if (parsedValue !== module.exports.initialValues.get(key)) { + obj[key] = parsedValues.get(key); + if (obj[borderTopWidth.property] && obj[borderTopWidth.property] === "medium") { + delete obj[borderTopWidth.property]; + } + } + } + } + return obj; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (val || typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderTopColor.js b/vanilla/node_modules/cssstyle/lib/properties/borderTopColor.js new file mode 100644 index 0000000..3c22b90 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderTopColor.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-top-color"; +const lineShorthand = "border-color"; +const positionShorthand = "border-top"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderTopStyle.js b/vanilla/node_modules/cssstyle/lib/properties/borderTopStyle.js new file mode 100644 index 0000000..c0bdf0e --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderTopStyle.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-top-style"; +const lineShorthand = "border-style"; +const positionShorthand = "border-top"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveKeywordValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderTopWidth.js b/vanilla/node_modules/cssstyle/lib/properties/borderTopWidth.js new file mode 100644 index 0000000..177fe83 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderTopWidth.js @@ -0,0 +1,57 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "border-top-width"; +const lineShorthand = "border-width"; +const positionShorthand = "border-top"; +const shorthand = "border"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const shorthandPriority = this._priorities.get(shorthand); + const linePriority = this._priorities.get(lineShorthand); + const positionPriority = this._priorities.get(positionShorthand); + const priority = + !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/borderWidth.js b/vanilla/node_modules/cssstyle/lib/properties/borderWidth.js new file mode 100644 index 0000000..1306f2e --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/borderWidth.js @@ -0,0 +1,111 @@ +"use strict"; + +const parsers = require("../parsers"); +const borderTopWidth = require("./borderTopWidth"); +const borderRightWidth = require("./borderRightWidth"); +const borderBottomWidth = require("./borderBottomWidth"); +const borderLeftWidth = require("./borderLeftWidth"); + +const property = "border-width"; +const shorthand = "border"; + +module.exports.shorthandFor = new Map([ + [borderTopWidth.property, borderTopWidth], + [borderRightWidth.property, borderRightWidth], + [borderBottomWidth.property, borderBottomWidth], + [borderLeftWidth.property, borderLeftWidth] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + const parsedValues = []; + if (Array.isArray(values) && values.length) { + if (values.length > 4) { + return; + } + for (const value of values) { + const parsedValue = parsers.resolveNumericValue([value], { + length: values.length, + type: "length" + }); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } + } else if (typeof values === "string") { + parsedValues.push(values); + } + if (parsedValues.length) { + switch (parsedValues.length) { + case 1: { + return parsedValues; + } + case 2: { + const [val1, val2] = parsedValues; + if (val1 === val2) { + return [val1]; + } + return parsedValues; + } + case 3: { + const [val1, val2, val3] = parsedValues; + if (val1 === val3) { + if (val1 === val2) { + return [val1]; + } + return [val1, val2]; + } + return parsedValues; + } + case 4: { + const [val1, val2, val3, val4] = parsedValues; + if (val2 === val4) { + if (val1 === val3) { + if (val1 === val2) { + return [val1]; + } + return [val1, val2]; + } + return [val1, val2, val3]; + } + return parsedValues; + } + default: + } + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._borderSetter(property, v, ""); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (Array.isArray(val) || typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._borderSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/bottom.js b/vanilla/node_modules/cssstyle/lib/properties/bottom.js new file mode 100644 index 0000000..af7bc58 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/bottom.js @@ -0,0 +1,47 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "bottom"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/clear.js b/vanilla/node_modules/cssstyle/lib/properties/clear.js new file mode 100644 index 0000000..28e9ef3 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/clear.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "clear"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveKeywordValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/clip.js b/vanilla/node_modules/cssstyle/lib/properties/clip.js new file mode 100644 index 0000000..a3db772 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/clip.js @@ -0,0 +1,73 @@ +"use strict"; +// deprecated +// @see https://drafts.csswg.org/css-masking-1/#clip-property + +const parsers = require("../parsers"); + +const property = "clip"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const { AST_TYPES } = parsers; + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const [{ name, type, value: itemValue }] = value; + switch (type) { + case AST_TYPES.FUNCTION: { + const values = parsers.splitValue(itemValue, { + delimiter: "," + }); + const parsedValues = []; + for (const item of values) { + const parsedValue = parsers.parseCSS(item, { context: "value" }, true); + const val = parsers.resolveNumericValue(parsedValue.children, { + type: "length" + }); + if (val) { + parsedValues.push(val); + } else { + return; + } + } + return `${name}(${parsedValues.join(", ")})`; + } + case AST_TYPES.GLOBAL_KEYWORD: + case AST_TYPES.IDENTIFIER: { + return name; + } + default: + } + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/color.js b/vanilla/node_modules/cssstyle/lib/properties/color.js new file mode 100644 index 0000000..d0ad35c --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/color.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/display.js b/vanilla/node_modules/cssstyle/lib/properties/display.js new file mode 100644 index 0000000..d331d54 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/display.js @@ -0,0 +1,210 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "display"; + +/* keywords */ +const displayOutside = ["block", "inline", "run-in"]; +const displayFlow = ["flow", "flow-root"]; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const { AST_TYPES } = parsers; + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length) { + switch (value.length) { + case 1: { + const [{ name, type }] = value; + switch (type) { + case AST_TYPES.GLOBAL_KEYWORD: { + return name; + } + case AST_TYPES.IDENTIFIER: { + if (name === "flow") { + return "block"; + } + return name; + } + default: + } + break; + } + case 2: { + const [part1, part2] = value; + const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name; + const val2 = part2.type === AST_TYPES.IDENTIFIER && part2.name; + if (val1 && val2) { + let outerValue = ""; + let innerValue = ""; + if (val1 === "list-item") { + outerValue = val2; + innerValue = val1; + } else if (val2 === "list-item") { + outerValue = val1; + innerValue = val2; + } else if (displayOutside.includes(val1)) { + outerValue = val1; + innerValue = val2; + } else if (displayOutside.includes(val2)) { + outerValue = val2; + innerValue = val1; + } + if (innerValue === "list-item") { + switch (outerValue) { + case "block": + case "flow": { + return innerValue; + } + case "flow-root": + case "inline": + case "run-in": { + return `${outerValue} ${innerValue}`; + } + default: + } + } else if (outerValue === "block") { + switch (innerValue) { + case "flow": { + return outerValue; + } + case "flow-root": + case "flex": + case "grid": + case "table": { + return innerValue; + } + case "ruby": { + return `${outerValue} ${innerValue}`; + } + default: + } + } else if (outerValue === "inline") { + switch (innerValue) { + case "flow": { + return outerValue; + } + case "flow-root": { + return `${outerValue}-block`; + } + case "flex": + case "grid": + case "table": { + return `${outerValue}-${innerValue}`; + } + case "ruby": { + return innerValue; + } + default: + } + } else if (outerValue === "run-in") { + switch (innerValue) { + case "flow": { + return outerValue; + } + case "flow-root": + case "flex": + case "grid": + case "table": + case "ruby": { + return `${outerValue} ${innerValue}`; + } + default: + } + } + } + break; + } + case 3: { + const [part1, part2, part3] = value; + const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name; + const val2 = part2.type === AST_TYPES.IDENTIFIER && part2.name; + const val3 = part3.type === AST_TYPES.IDENTIFIER && part3.name; + if (val1 && val2 && part3) { + let outerValue = ""; + let flowValue = ""; + let listItemValue = ""; + if (val1 === "list-item") { + listItemValue = val1; + if (displayFlow.includes(val2)) { + flowValue = val2; + outerValue = val3; + } else if (displayFlow.includes(val3)) { + flowValue = val3; + outerValue = val2; + } + } else if (val2 === "list-item") { + listItemValue = val2; + if (displayFlow.includes(val1)) { + flowValue = val1; + outerValue = val3; + } else if (displayFlow.includes(val3)) { + flowValue = val3; + outerValue = val1; + } + } else if (val3 === "list-item") { + listItemValue = val3; + if (displayFlow.includes(val1)) { + flowValue = val1; + outerValue = val2; + } else if (displayFlow.includes(val2)) { + flowValue = val2; + outerValue = val1; + } + } + if (outerValue && flowValue && listItemValue) { + switch (outerValue) { + case "block": { + if (flowValue === "flow") { + return listItemValue; + } + return `${flowValue} ${listItemValue}`; + } + case "inline": + case "run-in": { + if (flowValue === "flow") { + return `${outerValue} ${listItemValue}`; + } + return `${outerValue} ${flowValue} ${listItemValue}`; + } + } + } + } + break; + } + default: + } + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/flex.js b/vanilla/node_modules/cssstyle/lib/properties/flex.js new file mode 100644 index 0000000..084e99d --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/flex.js @@ -0,0 +1,178 @@ +"use strict"; + +const parsers = require("../parsers"); +const flexGrow = require("./flexGrow"); +const flexShrink = require("./flexShrink"); +const flexBasis = require("./flexBasis"); + +const property = "flex"; + +module.exports.initialValues = new Map([ + [flexGrow.property, "0"], + [flexShrink.property, "1"], + [flexBasis.property, "auto"] +]); + +module.exports.shorthandFor = new Map([ + [flexGrow.property, flexGrow], + [flexShrink.property, flexShrink], + [flexBasis.property, flexBasis] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const { AST_TYPES } = parsers; + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length) { + const flex = { + [flexGrow.property]: "1", + [flexShrink.property]: "1", + [flexBasis.property]: "0%" + }; + if (value.length === 1) { + const [{ isNumber, name, type, unit, value: itemValue }] = value; + switch (type) { + case AST_TYPES.CALC: { + if (isNumber) { + flex[flexGrow.property] = `${name}(${itemValue})`; + return flex; + } + flex[flexBasis.property] = `${name}(${itemValue})`; + return flex; + } + case AST_TYPES.DIMENSION: { + flex[flexBasis.property] = `${itemValue}${unit}`; + return flex; + } + case AST_TYPES.GLOBAL_KEYWORD: { + return name; + } + case AST_TYPES.IDENTIFIER: { + if (name === "none") { + return { + [flexGrow.property]: "0", + [flexShrink.property]: "0", + [flexBasis.property]: "auto" + }; + } + flex[flexBasis.property] = name; + return flex; + } + case AST_TYPES.NUMBER: { + flex[flexGrow.property] = itemValue; + return flex; + } + case AST_TYPES.PERCENTAGE: { + flex[flexBasis.property] = `${itemValue}%`; + return flex; + } + default: + } + } else { + const [val1, val2, val3] = value; + if (val1.type === AST_TYPES.CALC && val1.isNumber) { + flex[flexGrow.property] = `${val1.name}(${val1.value})`; + } else if (val1.type === AST_TYPES.NUMBER) { + flex[flexGrow.property] = val1.value; + } else { + return; + } + if (val3) { + if (val2.type === AST_TYPES.CALC && val2.isNumber) { + flex[flexShrink.property] = `${val2.name}(${val2.value})`; + } else if (val2.type === AST_TYPES.NUMBER) { + flex[flexShrink.property] = val2.value; + } else { + return; + } + if (val3.type === AST_TYPES.GLOBAL_KEYWORD || val3.type === AST_TYPES.IDENTIFIER) { + flex[flexBasis.property] = val3.name; + } else if (val3.type === AST_TYPES.CALC && !val3.isNumber) { + flex[flexBasis.property] = `${val3.name}(${val3.value})`; + } else if (val3.type === AST_TYPES.DIMENSION) { + flex[flexBasis.property] = `${val3.value}${val3.unit}`; + } else if (val3.type === AST_TYPES.PERCENTAGE) { + flex[flexBasis.property] = `${val3.value}%`; + } else { + return; + } + } else { + switch (val2.type) { + case AST_TYPES.CALC: { + if (val2.isNumber) { + flex[flexShrink.property] = `${val2.name}(${val2.value})`; + } else { + flex[flexBasis.property] = `${val2.name}(${val2.value})`; + } + break; + } + case AST_TYPES.DIMENSION: { + flex[flexBasis.property] = `${val2.value}${val2.unit}`; + break; + } + case AST_TYPES.NUMBER: { + flex[flexShrink.property] = val2.value; + break; + } + case AST_TYPES.PERCENTAGE: { + flex[flexBasis.property] = `${val2.value}%`; + break; + } + case AST_TYPES.IDENTIFIER: { + flex[flexBasis.property] = val2.name; + break; + } + default: { + return; + } + } + } + return flex; + } + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + for (const [longhand] of module.exports.shorthandFor) { + this._setProperty(longhand, ""); + } + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + const priority = this._priorities.get(property) ?? ""; + if (typeof val === "string") { + for (const [longhand] of module.exports.shorthandFor) { + this._setProperty(longhand, val, priority); + } + this._setProperty(property, val, priority); + } else if (val) { + const values = []; + for (const [longhand, value] of Object.entries(val)) { + values.push(value); + this._setProperty(longhand, value, priority); + } + this._setProperty(property, values.join(" "), priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/flexBasis.js b/vanilla/node_modules/cssstyle/lib/properties/flexBasis.js new file mode 100644 index 0000000..68bebc2 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/flexBasis.js @@ -0,0 +1,52 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "flex-basis"; +const shorthand = "flex"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._flexBoxSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/flexGrow.js b/vanilla/node_modules/cssstyle/lib/properties/flexGrow.js new file mode 100644 index 0000000..7789021 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/flexGrow.js @@ -0,0 +1,52 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "flex-grow"; +const shorthand = "flex"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue("flex-grow", v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0 + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._flexBoxSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/flexShrink.js b/vanilla/node_modules/cssstyle/lib/properties/flexShrink.js new file mode 100644 index 0000000..ed0abb4 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/flexShrink.js @@ -0,0 +1,52 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "flex-shrink"; +const shorthand = "flex"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0 + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._flexBoxSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/float.js b/vanilla/node_modules/cssstyle/lib/properties/float.js new file mode 100644 index 0000000..7080260 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/float.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "float"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveKeywordValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/floodColor.js b/vanilla/node_modules/cssstyle/lib/properties/floodColor.js new file mode 100644 index 0000000..7ef4fe8 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/floodColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "flood-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/font.js b/vanilla/node_modules/cssstyle/lib/properties/font.js new file mode 100644 index 0000000..17897f3 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/font.js @@ -0,0 +1,302 @@ +"use strict"; + +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"); + +const property = "font"; + +module.exports.shorthandFor = new Map([ + [fontStyle.property, fontStyle], + [fontVariant.property, fontVariant], + [fontWeight.property, fontWeight], + [fontSize.property, fontSize], + [lineHeight.property, lineHeight], + [fontFamily.property, fontFamily] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } else if (parsers.hasCalcFunc(v)) { + v = parsers.resolveCalc(v); + } + if (!parsers.isValidPropertyValue(property, v)) { + return; + } + const { AST_TYPES } = parsers; + const [fontBlock, ...families] = parsers.splitValue(v, { + delimiter: "," + }); + const [fontBlockA, fontBlockB] = parsers.splitValue(fontBlock, { + delimiter: "/" + }); + const font = { + [fontStyle.property]: "normal", + [fontVariant.property]: "normal", + [fontWeight.property]: "normal" + }; + const fontFamilies = new Set(); + if (fontBlockB) { + const [lineB, ...familiesB] = fontBlockB.trim().split(" "); + if (!lineB || !familiesB.length) { + return; + } + const lineHeightB = lineHeight.parse(lineB, { + global + }); + if (typeof lineHeightB !== "string") { + return; + } + const familyB = fontFamily.parse(familiesB.join(" "), { + globalObject, + caseSensitive: true + }); + if (typeof familyB === "string") { + fontFamilies.add(familyB); + } else { + return; + } + const parts = parsers.splitValue(fontBlockA.trim()); + const properties = [ + fontStyle.property, + fontVariant.property, + fontWeight.property, + fontSize.property + ]; + for (const part of parts) { + if (part === "normal") { + continue; + } else { + for (const longhand of properties) { + switch (longhand) { + case fontSize.property: { + const parsedValue = fontSize.parse(part, { + globalObject + }); + if (typeof parsedValue === "string") { + font[longhand] = parsedValue; + } + break; + } + case fontStyle.property: + case fontWeight.property: { + if (font[longhand] === "normal") { + const longhandItem = module.exports.shorthandFor.get(longhand); + const parsedValue = longhandItem.parse(part, { + globalObject + }); + if (typeof parsedValue === "string") { + font[longhand] = parsedValue; + } + } + break; + } + case fontVariant.property: { + if (font[longhand] === "normal") { + const parsedValue = fontVariant.parse(part, { + globalObject + }); + if (typeof parsedValue === "string") { + if (parsedValue === "small-cap") { + font[longhand] = parsedValue; + } else if (parsedValue !== "normal") { + return; + } + } + } + break; + } + default: + } + } + } + } + if (Object.hasOwn(font, fontSize.property)) { + font[lineHeight.property] = lineHeightB; + } else { + return; + } + } else { + const revParts = parsers.splitValue(fontBlockA.trim()).toReversed(); + if (revParts.length === 1) { + const [part] = revParts; + const value = parsers.parsePropertyValue(property, part, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const [{ name, type }] = value; + if (type === AST_TYPES.GLOBAL_KEYWORD) { + return { + [fontStyle.property]: name, + [fontVariant.property]: name, + [fontWeight.property]: name, + [fontSize.property]: name, + [lineHeight.property]: name, + [fontFamily.property]: name + }; + } + } + return; + } + const properties = [ + fontStyle.property, + fontVariant.property, + fontWeight.property, + lineHeight.property + ]; + for (const longhand of properties) { + font[longhand] = "normal"; + } + const revFontFamily = []; + let fontSizeA; + for (const part of revParts) { + if (fontSizeA) { + if (/^normal$/i.test(part)) { + continue; + } else { + for (const longhand of properties) { + switch (longhand) { + case fontStyle.property: + case fontWeight.property: + case lineHeight.property: { + if (font[longhand] === "normal") { + const longhandItem = module.exports.shorthandFor.get(longhand); + const parsedValue = longhandItem.parse(part, { + globalObject + }); + if (typeof parsedValue === "string") { + font[longhand] = parsedValue; + } + } + break; + } + case fontVariant.property: { + if (font[longhand] === "normal") { + const parsedValue = fontVariant.parse(part, { + globalObject + }); + if (typeof parsedValue === "string") { + if (parsedValue === "small-cap") { + font[longhand] = parsedValue; + } else if (parsedValue !== "normal") { + return; + } + } + } + break; + } + default: + } + } + } + } else { + const parsedFontSize = fontSize.parse(part, { + globalObject + }); + if (typeof parsedFontSize === "string") { + fontSizeA = parsedFontSize; + } else { + const parsedFontFamily = fontFamily.parse(part, { + globalObject, + caseSensitive: true + }); + if (typeof parsedFontFamily === "string") { + revFontFamily.push(parsedFontFamily); + } else { + return; + } + } + } + } + const family = fontFamily.parse(revFontFamily.toReversed().join(" "), { + globalObject, + caseSensitive: true + }); + if (fontSizeA && family) { + font[fontSize.property] = fontSizeA; + fontFamilies.add(fontFamily.parse(family)); + } else { + return; + } + } + for (const family of families) { + const parsedFontFamily = fontFamily.parse(family, { + globalObject, + caseSensitive: true + }); + if (parsedFontFamily) { + fontFamilies.add(parsedFontFamily); + } else { + return; + } + } + font[fontFamily.property] = [...fontFamilies].join(", "); + return font; +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (v === "" || parsers.hasVarFunc(v)) { + for (const [key] of module.exports.shorthandFor) { + this._setProperty(key, ""); + } + this._setProperty(property, v); + } else { + const obj = module.exports.parse(v, { + globalObject: this._global + }); + if (!obj) { + return; + } + const priority = this._priorities.get(property) ?? ""; + const str = new Set(); + for (const [key] of module.exports.shorthandFor) { + const val = obj[key]; + if (typeof val === "string") { + this._setProperty(key, val, priority); + if (val && val !== "normal" && !str.has(val)) { + if (key === lineHeight.property) { + str.add(`/ ${val}`); + } else { + str.add(val); + } + } + } + } + this._setProperty(property, [...str].join(" "), priority); + } + }, + get() { + const val = this.getPropertyValue(property); + if (parsers.hasVarFunc(val)) { + return val; + } + const str = new Set(); + for (const [key] of module.exports.shorthandFor) { + const v = this.getPropertyValue(key); + if (parsers.hasVarFunc(v)) { + return ""; + } + if (v && v !== "normal" && !str.has(v)) { + if (key === lineHeight.property) { + str.add(`/ ${v}`); + } else { + str.add(`${v}`); + } + } + } + return [...str].join(" "); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/fontFamily.js b/vanilla/node_modules/cssstyle/lib/properties/fontFamily.js new file mode 100644 index 0000000..e3fc7ee --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/fontFamily.js @@ -0,0 +1,98 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "font-family"; +const shorthand = "font"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const { AST_TYPES } = parsers; + const values = parsers.splitValue(v, { + delimiter: "," + }); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + caseSensitive: true, + inArray: true + }); + if (Array.isArray(value) && value.length) { + if (value.length === 1) { + const [{ name, type, value: itemValue }] = value; + switch (type) { + case AST_TYPES.FUNCTION: { + parsedValues.push(`${name}(${itemValue})`); + break; + } + case AST_TYPES.GLOBAL_KEYWORD: + case AST_TYPES.IDENTIFIER: { + if (name === "undefined") { + return; + } + parsedValues.push(name); + break; + } + case "String": { + const parsedValue = itemValue.replaceAll("\\", "").replaceAll('"', '\\"'); + parsedValues.push(`"${parsedValue}"`); + break; + } + default: { + return; + } + } + } else { + const parts = []; + for (const item of value) { + const { name, type } = item; + if (type !== AST_TYPES.IDENTIFIER) { + return; + } + parts.push(name); + } + const parsedValue = parts.join(" ").replaceAll("\\", "").replaceAll('"', '\\"'); + parsedValues.push(`"${parsedValue}"`); + } + } else if (typeof value === "string") { + parsedValues.push(value); + } else { + return; + } + } + if (parsedValues.length) { + return parsedValues.join(", "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/fontSize.js b/vanilla/node_modules/cssstyle/lib/properties/fontSize.js new file mode 100644 index 0000000..80b015e --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/fontSize.js @@ -0,0 +1,53 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "font-size"; +const shorthand = "font"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/fontStyle.js b/vanilla/node_modules/cssstyle/lib/properties/fontStyle.js new file mode 100644 index 0000000..f07a17d --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/fontStyle.js @@ -0,0 +1,69 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "font-style"; +const shorthand = "font"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const { AST_TYPES } = parsers; + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length) { + if (value.length === 1) { + const [{ name, type }] = value; + switch (type) { + case AST_TYPES.GLOBAL_KEYWORD: + case AST_TYPES.IDENTIFIER: { + return name; + } + default: + } + } else if (value.length === 2) { + const [part1, part2] = value; + const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name; + const val2 = parsers.resolveNumericValue([part2], { + type: "angle" + }); + if (val1 && val1 === "oblique" && val2) { + return `${val1} ${val2}`; + } + } + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/fontVariant.js b/vanilla/node_modules/cssstyle/lib/properties/fontVariant.js new file mode 100644 index 0000000..515b75e --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/fontVariant.js @@ -0,0 +1,66 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "font-variant"; +const shorthand = "font"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.splitValue(v); + const parsedValues = []; + for (const val of values) { + const value = parsers.parsePropertyValue(property, val, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveFunctionValue(value); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } else if (typeof value === "string") { + parsedValues.push(value); + } + } + if (parsedValues.length) { + if (parsedValues.length > 1) { + if (parsedValues.includes("normal") || parsedValues.includes("none")) { + return; + } + } + return parsedValues.join(" "); + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/fontWeight.js b/vanilla/node_modules/cssstyle/lib/properties/fontWeight.js new file mode 100644 index 0000000..8087e07 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/fontWeight.js @@ -0,0 +1,57 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "font-weight"; +const shorthand = "font"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + const parsedValue = parsers.resolveNumericValue(value, { + min: 1, + max: 1000 + }); + if (!parsedValue) { + return; + } + return parsedValue; + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/height.js b/vanilla/node_modules/cssstyle/lib/properties/height.js new file mode 100644 index 0000000..1e3bd78 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/height.js @@ -0,0 +1,48 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "height"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/left.js b/vanilla/node_modules/cssstyle/lib/properties/left.js new file mode 100644 index 0000000..8cea211 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/left.js @@ -0,0 +1,47 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "left"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/lightingColor.js b/vanilla/node_modules/cssstyle/lib/properties/lightingColor.js new file mode 100644 index 0000000..a007bd5 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/lightingColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "lighting-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/lineHeight.js b/vanilla/node_modules/cssstyle/lib/properties/lineHeight.js new file mode 100644 index 0000000..e1f4b37 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/lineHeight.js @@ -0,0 +1,52 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "line-height"; +const shorthand = "font"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0 + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/margin.js b/vanilla/node_modules/cssstyle/lib/properties/margin.js new file mode 100644 index 0000000..ffb8704 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/margin.js @@ -0,0 +1,77 @@ +"use strict"; + +const parsers = require("../parsers"); +const marginTop = require("./marginTop"); +const marginRight = require("./marginRight"); +const marginBottom = require("./marginBottom"); +const marginLeft = require("./marginLeft"); + +const property = "margin"; + +module.exports.position = "edges"; + +module.exports.shorthandFor = new Map([ + [marginTop.property, marginTop], + [marginRight.property, marginRight], + [marginBottom.property, marginBottom], + [marginLeft.property, marginLeft] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + const parsedValues = []; + if (Array.isArray(values) && values.length) { + if (values.length > 4) { + return; + } + for (const value of values) { + const parsedValue = parsers.resolveNumericValue([value], { + length: values.length, + type: "length" + }); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } + } else if (typeof values === "string") { + parsedValues.push(values); + } + if (parsedValues.length) { + return parsedValues; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + for (const [longhand] of module.exports.shorthandFor) { + this._setProperty(longhand, ""); + } + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (Array.isArray(val) || typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._positionShorthandSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/marginBottom.js b/vanilla/node_modules/cssstyle/lib/properties/marginBottom.js new file mode 100644 index 0000000..c3b1e0b --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/marginBottom.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "margin-bottom"; +const shorthand = "margin"; + +module.exports.position = "bottom"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._positionLonghandSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/marginLeft.js b/vanilla/node_modules/cssstyle/lib/properties/marginLeft.js new file mode 100644 index 0000000..f70fe4a --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/marginLeft.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "margin-left"; +const shorthand = "margin"; + +module.exports.position = "left"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._positionLonghandSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/marginRight.js b/vanilla/node_modules/cssstyle/lib/properties/marginRight.js new file mode 100644 index 0000000..8ec0234 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/marginRight.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "margin-right"; +const shorthand = "margin"; + +module.exports.position = "right"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._positionLonghandSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/marginTop.js b/vanilla/node_modules/cssstyle/lib/properties/marginTop.js new file mode 100644 index 0000000..af8f842 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/marginTop.js @@ -0,0 +1,54 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "margin-top"; +const shorthand = "margin"; + +module.exports.position = "top"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._positionLonghandSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/opacity.js b/vanilla/node_modules/cssstyle/lib/properties/opacity.js new file mode 100644 index 0000000..119fd28 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/opacity.js @@ -0,0 +1,47 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "opacity"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + clamp: true + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/outlineColor.js b/vanilla/node_modules/cssstyle/lib/properties/outlineColor.js new file mode 100644 index 0000000..6e44b5a --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/outlineColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "outline-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/padding.js b/vanilla/node_modules/cssstyle/lib/properties/padding.js new file mode 100644 index 0000000..0168aa6 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/padding.js @@ -0,0 +1,78 @@ +"use strict"; + +const parsers = require("../parsers"); +const paddingTop = require("./paddingTop"); +const paddingRight = require("./paddingRight"); +const paddingBottom = require("./paddingBottom"); +const paddingLeft = require("./paddingLeft"); + +const property = "padding"; + +module.exports.position = "edges"; + +module.exports.shorthandFor = new Map([ + [paddingTop.property, paddingTop], + [paddingRight.property, paddingRight], + [paddingBottom.property, paddingBottom], + [paddingLeft.property, paddingLeft] +]); + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const values = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + const parsedValues = []; + if (Array.isArray(values) && values.length) { + if (values.length > 4) { + return; + } + for (const value of values) { + const parsedValue = parsers.resolveNumericValue([value], { + length: values.length, + min: 0, + type: "length" + }); + if (!parsedValue) { + return; + } + parsedValues.push(parsedValue); + } + } else if (typeof values === "string") { + parsedValues.push(values); + } + if (parsedValues.length) { + return parsedValues; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + for (const [longhand] of module.exports.shorthandFor) { + this._setProperty(longhand, ""); + } + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (Array.isArray(val) || typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._positionShorthandSetter(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/paddingBottom.js b/vanilla/node_modules/cssstyle/lib/properties/paddingBottom.js new file mode 100644 index 0000000..0b03592 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/paddingBottom.js @@ -0,0 +1,55 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "padding-bottom"; +const shorthand = "padding"; + +module.exports.position = "bottom"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._positionLonghandSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/paddingLeft.js b/vanilla/node_modules/cssstyle/lib/properties/paddingLeft.js new file mode 100644 index 0000000..1b6b13e --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/paddingLeft.js @@ -0,0 +1,55 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "padding-left"; +const shorthand = "padding"; + +module.exports.position = "left"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._positionLonghandSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/paddingRight.js b/vanilla/node_modules/cssstyle/lib/properties/paddingRight.js new file mode 100644 index 0000000..f7088bd --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/paddingRight.js @@ -0,0 +1,55 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "padding-right"; +const shorthand = "padding"; + +module.exports.position = "right"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._positionLonghandSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/paddingTop.js b/vanilla/node_modules/cssstyle/lib/properties/paddingTop.js new file mode 100644 index 0000000..32e9f76 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/paddingTop.js @@ -0,0 +1,55 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "padding-top"; +const shorthand = "padding"; + +module.exports.position = "top"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(shorthand, ""); + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = + !this._priorities.get(shorthand) && this._priorities.has(property) + ? this._priorities.get(property) + : ""; + this._positionLonghandSetter(property, val, priority, shorthand); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/right.js b/vanilla/node_modules/cssstyle/lib/properties/right.js new file mode 100644 index 0000000..a28687a --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/right.js @@ -0,0 +1,47 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "right"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/stopColor.js b/vanilla/node_modules/cssstyle/lib/properties/stopColor.js new file mode 100644 index 0000000..4ab8871 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/stopColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "stop-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/top.js b/vanilla/node_modules/cssstyle/lib/properties/top.js new file mode 100644 index 0000000..29794a8 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/top.js @@ -0,0 +1,47 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "top"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitBorderAfterColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitBorderAfterColor.js new file mode 100644 index 0000000..7190ec3 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitBorderAfterColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-border-after-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitBorderBeforeColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitBorderBeforeColor.js new file mode 100644 index 0000000..f6008ff --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitBorderBeforeColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-border-before-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitBorderEndColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitBorderEndColor.js new file mode 100644 index 0000000..3870118 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitBorderEndColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-border-end-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitBorderStartColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitBorderStartColor.js new file mode 100644 index 0000000..96bec13 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitBorderStartColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-border-start-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitColumnRuleColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitColumnRuleColor.js new file mode 100644 index 0000000..087695f --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitColumnRuleColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-column-rule-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitTapHighlightColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitTapHighlightColor.js new file mode 100644 index 0000000..abda140 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitTapHighlightColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-tap-highlight-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitTextEmphasisColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitTextEmphasisColor.js new file mode 100644 index 0000000..049babe --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitTextEmphasisColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-text-emphasis-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitTextFillColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitTextFillColor.js new file mode 100644 index 0000000..027835d --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitTextFillColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-text-fill-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/webkitTextStrokeColor.js b/vanilla/node_modules/cssstyle/lib/properties/webkitTextStrokeColor.js new file mode 100644 index 0000000..e4f7224 --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/webkitTextStrokeColor.js @@ -0,0 +1,45 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "-webkit-text-stroke-color"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveColorValue(value); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; diff --git a/vanilla/node_modules/cssstyle/lib/properties/width.js b/vanilla/node_modules/cssstyle/lib/properties/width.js new file mode 100644 index 0000000..91d5a1a --- /dev/null +++ b/vanilla/node_modules/cssstyle/lib/properties/width.js @@ -0,0 +1,48 @@ +"use strict"; + +const parsers = require("../parsers"); + +const property = "width"; + +module.exports.parse = (v, opt = {}) => { + const { globalObject } = opt; + if (v === "") { + return v; + } + const value = parsers.parsePropertyValue(property, v, { + globalObject, + inArray: true + }); + if (Array.isArray(value) && value.length === 1) { + return parsers.resolveNumericValue(value, { + min: 0, + type: "length" + }); + } else if (typeof value === "string") { + return value; + } +}; + +module.exports.definition = { + set(v) { + v = parsers.prepareValue(v); + if (parsers.hasVarFunc(v)) { + this._setProperty(property, v); + } else { + const val = module.exports.parse(v, { + globalObject: this._global + }); + if (typeof val === "string") { + const priority = this._priorities.get(property) ?? ""; + this._setProperty(property, val, priority); + } + } + }, + get() { + return this.getPropertyValue(property); + }, + enumerable: true, + configurable: true +}; + +module.exports.property = property; |
