cssstyle
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -17,5 +17,10 @@ 'use strict'; | ||
window: true, | ||
describe: true, | ||
it: true, | ||
test: true, | ||
expect: true, | ||
}, | ||
plugins: ['prettier'], | ||
rules: { | ||
'no-prototype-builtins': 'off', | ||
'prettier/prettier': [ | ||
@@ -22,0 +27,0 @@ 'warn', |
'use strict'; | ||
// autogenerated - 2/3/2019 | ||
// autogenerated - 7/1/2019 | ||
@@ -15,2 +15,3 @@ /* | ||
allProperties.add('align-self'); | ||
allProperties.add('alignment-adjust'); | ||
allProperties.add('alignment-baseline'); | ||
@@ -29,2 +30,3 @@ allProperties.add('all'); | ||
allProperties.add('azimuth'); | ||
allProperties.add('backface-visibility'); | ||
allProperties.add('background'); | ||
@@ -61,11 +63,27 @@ allProperties.add('background-attachment'); | ||
allProperties.add('border-bottom-color'); | ||
allProperties.add('border-bottom-fit-length'); | ||
allProperties.add('border-bottom-fit-width'); | ||
allProperties.add('border-bottom-image'); | ||
allProperties.add('border-bottom-left-fit-width'); | ||
allProperties.add('border-bottom-left-image'); | ||
allProperties.add('border-bottom-left-radius'); | ||
allProperties.add('border-bottom-right-fit-length'); | ||
allProperties.add('border-bottom-right-fit-width'); | ||
allProperties.add('border-bottom-right-image'); | ||
allProperties.add('border-bottom-right-radius'); | ||
allProperties.add('border-bottom-style'); | ||
allProperties.add('border-bottom-width'); | ||
allProperties.add('border-bottoml-eft-fit-length'); | ||
allProperties.add('border-boundary'); | ||
allProperties.add('border-break'); | ||
allProperties.add('border-collapse'); | ||
allProperties.add('border-color'); | ||
allProperties.add('border-corner-fit'); | ||
allProperties.add('border-corner-image'); | ||
allProperties.add('border-corner-image-transform'); | ||
allProperties.add('border-end-end-radius'); | ||
allProperties.add('border-end-start-radius'); | ||
allProperties.add('border-fit'); | ||
allProperties.add('border-fit-length'); | ||
allProperties.add('border-fit-width'); | ||
allProperties.add('border-image'); | ||
@@ -76,2 +94,3 @@ allProperties.add('border-image-outset'); | ||
allProperties.add('border-image-source'); | ||
allProperties.add('border-image-transform'); | ||
allProperties.add('border-image-width'); | ||
@@ -92,2 +111,5 @@ allProperties.add('border-inline'); | ||
allProperties.add('border-left-color'); | ||
allProperties.add('border-left-fit-length'); | ||
allProperties.add('border-left-fit-width'); | ||
allProperties.add('border-left-image'); | ||
allProperties.add('border-left-style'); | ||
@@ -98,2 +120,5 @@ allProperties.add('border-left-width'); | ||
allProperties.add('border-right-color'); | ||
allProperties.add('border-right-fit-length'); | ||
allProperties.add('border-right-fit-width'); | ||
allProperties.add('border-right-image'); | ||
allProperties.add('border-right-style'); | ||
@@ -107,3 +132,12 @@ allProperties.add('border-right-width'); | ||
allProperties.add('border-top-color'); | ||
allProperties.add('border-top-fit-length'); | ||
allProperties.add('border-top-fit-width'); | ||
allProperties.add('border-top-image'); | ||
allProperties.add('border-top-left-fit-length'); | ||
allProperties.add('border-top-left-fit-width'); | ||
allProperties.add('border-top-left-image'); | ||
allProperties.add('border-top-left-radius'); | ||
allProperties.add('border-top-right-fit-length'); | ||
allProperties.add('border-top-right-fit-width'); | ||
allProperties.add('border-top-right-image'); | ||
allProperties.add('border-top-right-radius'); | ||
@@ -131,3 +165,5 @@ allProperties.add('border-top-style'); | ||
allProperties.add('color'); | ||
allProperties.add('color-adjust'); | ||
allProperties.add('color-interpolation-filters'); | ||
allProperties.add('color-scheme'); | ||
allProperties.add('column-count'); | ||
@@ -156,2 +192,8 @@ allProperties.add('column-fill'); | ||
allProperties.add('dominant-baseline'); | ||
allProperties.add('drop-initial-after-adjust'); | ||
allProperties.add('drop-initial-after-align'); | ||
allProperties.add('drop-initial-before-adjust'); | ||
allProperties.add('drop-initial-before-align'); | ||
allProperties.add('drop-initial-size'); | ||
allProperties.add('drop-initial-value'); | ||
allProperties.add('elevation'); | ||
@@ -202,2 +244,3 @@ allProperties.add('empty-cells'); | ||
allProperties.add('footnote-policy'); | ||
allProperties.add('forced-color-adjust'); | ||
allProperties.add('gap'); | ||
@@ -233,2 +276,3 @@ allProperties.add('glyph-orientation-vertical'); | ||
allProperties.add('initial-letters-wrap'); | ||
allProperties.add('inline-box-align'); | ||
allProperties.add('inline-size'); | ||
@@ -256,2 +300,6 @@ allProperties.add('inline-sizing'); | ||
allProperties.add('line-snap'); | ||
allProperties.add('line-stacking'); | ||
allProperties.add('line-stacking-ruby'); | ||
allProperties.add('line-stacking-shift'); | ||
allProperties.add('line-stacking-strategy'); | ||
allProperties.add('list-style'); | ||
@@ -349,2 +397,4 @@ allProperties.add('list-style-image'); | ||
allProperties.add('pause-before'); | ||
allProperties.add('perspective'); | ||
allProperties.add('perspective-origin'); | ||
allProperties.add('pitch'); | ||
@@ -357,9 +407,5 @@ allProperties.add('pitch-range'); | ||
allProperties.add('position'); | ||
allProperties.add('presentation-level'); | ||
allProperties.add('quotes'); | ||
allProperties.add('region-fragment'); | ||
allProperties.add('resize'); | ||
allProperties.add('rest'); | ||
allProperties.add('rest-after'); | ||
allProperties.add('rest-before'); | ||
allProperties.add('richness'); | ||
@@ -403,3 +449,2 @@ allProperties.add('right'); | ||
allProperties.add('speak'); | ||
allProperties.add('speak-as'); | ||
allProperties.add('speak-header'); | ||
@@ -426,2 +471,3 @@ allProperties.add('speak-numeral'); | ||
allProperties.add('text-group-align'); | ||
allProperties.add('text-height'); | ||
allProperties.add('text-indent'); | ||
@@ -442,2 +488,3 @@ allProperties.add('text-justify'); | ||
allProperties.add('transform-origin'); | ||
allProperties.add('transform-style'); | ||
allProperties.add('transition'); | ||
@@ -452,10 +499,3 @@ allProperties.add('transition-delay'); | ||
allProperties.add('visibility'); | ||
allProperties.add('voice-balance'); | ||
allProperties.add('voice-duration'); | ||
allProperties.add('voice-family'); | ||
allProperties.add('voice-pitch'); | ||
allProperties.add('voice-range'); | ||
allProperties.add('voice-rate'); | ||
allProperties.add('voice-stress'); | ||
allProperties.add('voice-volume'); | ||
allProperties.add('volume'); | ||
@@ -462,0 +502,0 @@ allProperties.add('white-space'); |
'use strict'; | ||
// autogenerated - 3/27/2019 | ||
// autogenerated - 7/1/2019 | ||
@@ -5,0 +5,0 @@ /* |
@@ -24,3 +24,3 @@ /********************************************************************* | ||
var integerRegEx = /^[-+]?[0-9]+$/; | ||
var numberRegEx = /^[-+]?[0-9]*\.[0-9]+$/; | ||
var numberRegEx = /^[-+]?[0-9]*\.?[0-9]+$/; | ||
var lengthRegEx = /^(0|[-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw))$/; | ||
@@ -30,3 +30,3 @@ var percentRegEx = /^[-+]?[0-9]*\.?[0-9]+%$/; | ||
var stringRegEx = /^("[^"]*"|'[^']*')$/; | ||
var colorRegEx1 = /^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])?$/; | ||
var colorRegEx1 = /^#([0-9a-fA-F]{3,4}){1,2}$/; | ||
var colorRegEx2 = /^rgb\(([^)]*)\)$/; | ||
@@ -292,7 +292,12 @@ var colorRegEx3 = /^rgba\(([^)]*)\)$/; | ||
var res = colorRegEx1.exec(val); | ||
// is it #aaa or #ababab | ||
// is it #aaa, #ababab, #aaaa, #abababaa | ||
if (res) { | ||
var defaultHex = val.substr(1); | ||
var hex = val.substr(1); | ||
if (hex.length === 3) { | ||
if (hex.length === 3 || hex.length === 4) { | ||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | ||
if (defaultHex.length === 4) { | ||
hex = hex + defaultHex[3] + defaultHex[3]; | ||
} | ||
} | ||
@@ -302,2 +307,8 @@ red = parseInt(hex.substr(0, 2), 16); | ||
blue = parseInt(hex.substr(4, 2), 16); | ||
if (hex.length === 8) { | ||
var hexAlpha = hex.substr(6, 2); | ||
var hexAlphaToRgbaAlpha = Number((parseInt(hexAlpha, 16) / 255).toFixed(3)); | ||
return 'rgba(' + red + ', ' + green + ', ' + blue + ', ' + hexAlphaToRgbaAlpha + ')'; | ||
} | ||
return 'rgb(' + red + ', ' + green + ', ' + blue + ')'; | ||
@@ -304,0 +315,0 @@ } |
'use strict'; | ||
// autogenerated - 3/27/2019 | ||
// autogenerated - 7/1/2019 | ||
@@ -1043,5 +1043,12 @@ /* | ||
function fontSize_local_fn_parse(v) { | ||
const valueAsString = String(v).toLowerCase(); | ||
const optionalArguments = fontSize_local_var_absoluteSizes.concat(fontSize_local_var_relativeSizes); | ||
const isOptionalArgument = optionalArguments.some(stringValue => stringValue.toLowerCase() === valueAsString); | ||
return isOptionalArgument ? valueAsString : external_dependency_parsers_0.parseMeasurement(v); | ||
} | ||
fontSize_export_definition = { | ||
set: function (v) { | ||
this._setProperty('font-size', v); | ||
this._setProperty('font-size', fontSize_local_fn_parse(v)); | ||
}, | ||
@@ -1048,0 +1055,0 @@ get: function () { |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var valueType = require('../parsers').valueType; | ||
var parseMeasurement = require('../parsers').parseMeasurement; | ||
@@ -20,5 +21,14 @@ var absoluteSizes = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large']; | ||
function parse(v) { | ||
const valueAsString = String(v).toLowerCase(); | ||
const optionalArguments = absoluteSizes.concat(relativeSizes); | ||
const isOptionalArgument = optionalArguments.some( | ||
stringValue => stringValue.toLowerCase() === valueAsString | ||
); | ||
return isOptionalArgument ? valueAsString : parseMeasurement(v); | ||
} | ||
module.exports.definition = { | ||
set: function(v) { | ||
this._setProperty('font-size', v); | ||
this._setProperty('font-size', parse(v)); | ||
}, | ||
@@ -25,0 +35,0 @@ get: function() { |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"homepage": "https://github.com/jsakas/CSSStyleDeclaration", | ||
@@ -17,2 +17,7 @@ "maintainers": [ | ||
"url": "https://jon.sakas.co/" | ||
}, | ||
{ | ||
"name": "Rafał Ruciński", | ||
"email": "fatfisz@gmail.com", | ||
"url": "https://fatfisz.com" | ||
} | ||
@@ -25,17 +30,2 @@ ], | ||
"url": "https://github.com/chad3814" | ||
}, | ||
{ | ||
"name": "Rafał Ruciński", | ||
"email": "fatfisz@gmail.com", | ||
"url": "https://fatfisz.com" | ||
}, | ||
{ | ||
"name": "Nikita Vasilyev", | ||
"email": "me@elv1s.ru" | ||
}, | ||
{ | ||
"name": "Davide P. Cervone" | ||
}, | ||
{ | ||
"name": "Forbes Lindesay" | ||
} | ||
@@ -50,3 +40,3 @@ ], | ||
"dependencies": { | ||
"cssom": "0.3.x" | ||
"cssom": "~0.3.6" | ||
}, | ||
@@ -58,10 +48,10 @@ "devDependencies": { | ||
"babylon": "~6.18.0", | ||
"eslint": "5.13.0", | ||
"eslint-config-prettier": "4.0.0", | ||
"eslint-plugin-prettier": "3.0.1", | ||
"nodeunit": "~0.11.3", | ||
"eslint": "~6.0.0", | ||
"eslint-config-prettier": "~6.0.0", | ||
"eslint-plugin-prettier": "~3.1.0", | ||
"jest": "^24.8.0", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "1.16.4", | ||
"prettier": "~1.18.0", | ||
"request": "^2.88.0", | ||
"resolve": "~1.8.1" | ||
"resolve": "~1.11.1" | ||
}, | ||
@@ -75,7 +65,11 @@ "scripts": { | ||
"lint:fix": "eslint . --fix --max-warnings 0", | ||
"prepublishOnly": "npm run test-ci", | ||
"test": "npm run generate && nodeunit tests", | ||
"test-ci": "npm run lint && npm run test" | ||
"prepublishOnly": "npm run lint && npm run test", | ||
"test": "npm run generate && jest", | ||
"test-ci": "npm run lint && npm run test && codecov", | ||
"update-authors": "git log --format=\"%aN <%aE>\" | sort -f | uniq > AUTHORS" | ||
}, | ||
"license": "MIT" | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=8" | ||
} | ||
} |
# CSSStyleDeclaration | ||
[![NpmVersion](https://img.shields.io/npm/v/cssstyle.svg)](https://www.npmjs.com/package/cssstyle) [![Build Status](https://travis-ci.org/jsakas/CSSStyleDeclaration.svg?branch=master)](https://travis-ci.org/jsakas/CSSStyleDeclaration) | ||
A Node JS implementation of the CSS Object Model [CSSStyleDeclaration interface](https://www.w3.org/TR/cssom-1/#the-cssstyledeclaration-interface). | ||
CSSStyleDeclaration is a work-a-like to the CSSStyleDeclaration class in Nikita Vasilyev's [CSSOM](https://github.com/NV/CSSOM). I made it so that when using [jQuery in node](https://github.com/tmtk75/node-jquery) setting css attributes via $.fn.css() would work. node-jquery uses [jsdom](https://github.com/tmpvar/jsdom) to create a DOM to use in node. jsdom uses CSSOM for styling, and CSSOM's implementation of the [CSSStyleDeclaration](http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration) doesn't support [CSS2Properties](http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties), which is how jQuery's [$.fn.css()](http://api.jquery.com/css/) operates. | ||
[![NpmVersion](https://img.shields.io/npm/v/cssstyle.svg)](https://www.npmjs.com/package/cssstyle) [![Build Status](https://travis-ci.org/jsakas/CSSStyleDeclaration.svg?branch=master)](https://travis-ci.org/jsakas/CSSStyleDeclaration) [![codecov](https://codecov.io/gh/jsakas/CSSStyleDeclaration/branch/master/graph/badge.svg)](https://codecov.io/gh/jsakas/CSSStyleDeclaration) | ||
### Why not just issue a pull request? | ||
--- | ||
Well, NV wants to keep CSSOM fast (which I can appreciate) and CSS2Properties aren't required by the standard (though every browser has the interface). So I figured the path of least resistance would be to just modify this one class, publish it as a node module (that requires CSSOM) and then make a pull request of jsdom to use it. | ||
#### Background | ||
### How do I test this code? | ||
This package is an extension of the CSSStyleDeclaration class in Nikita Vasilyev's [CSSOM](https://github.com/NV/CSSOM) with added support for CSS 2 & 3 properties. The primary use case is for testing browser code in a Node environment. | ||
`npm test` should do the trick, assuming you have the dev dependencies installed: | ||
It was originally created by Chad Walker, it is now maintaind by Jon Sakas and other open source contributors. | ||
``` | ||
$ npm test | ||
tests | ||
✔ Verify Has Properties | ||
✔ Verify Has Functions | ||
✔ Verify Has Special Properties | ||
✔ Test From Style String | ||
✔ Test From Properties | ||
✔ Test Shorthand Properties | ||
✔ Test width and height Properties and null and empty strings | ||
✔ Test Implicit Properties | ||
``` | ||
Bug reports and pull requests are welcome. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
1436775
199
7776
1
16
Updatedcssom@~0.3.6