diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 7af45ca96..8a9c3d843 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -22,10 +22,6 @@ merge of your pull request! **Why**: - - -**How**: - **Checklist**: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cb5e9173..552458ef6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: jobs: node_tests: - name: 'Test stylus on ${{matrix.os}} with node16' + name: 'Test stylus on ${{matrix.os}} with node18' strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] @@ -22,7 +22,7 @@ jobs: - uses: actions/setup-node@v3 with: # The Node.js version to configure - node-version: '16' + node-version: '18' - name: Install npm dependencies run: npm install - name: Print node & npm version @@ -36,7 +36,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node: [10, 12, 14, 18] + node: [10, 12, 14, 16, 20] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -96,3 +96,23 @@ jobs: run: npm install - name: Run nyc run: npx nyc@latest npm run test + + deno_tests: + name: 'Test stylus on ${{matrix.os}} with latest stable deno' + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + # Pull repo to test machine + - uses: actions/checkout@v3 + # Configures the deno version used on GitHub-hosted runners + - uses: denoland/setup-deno@v1 + with: + # Run with latest stable Deno + deno-version: v1.x + - name: Print deno version + # Output useful info for debugging. + run: deno --version + - name: Run Test + run: deno run -A deno/test.ts diff --git a/deno/test.ts b/deno/test.ts new file mode 100644 index 000000000..0156bf0ed --- /dev/null +++ b/deno/test.ts @@ -0,0 +1,33 @@ +import Mocha from "mocha"; + +import fs from "node:fs"; +import path from "node:path"; +import process from "node:process"; + +globalThis.process = process; + +const mocha = new Mocha({ + bail: true, + checkLeaks: true, + require: ["chai"], + reporter: "dot", +}); + +const testDirs = ["test/", "test/middleware/"]; + +testDirs.forEach((testDir) => { + fs + .readdirSync(testDir) + .filter(function (file) { + if (testDir === "test/" && file === "deno.js") return false; + + return file.slice(-3) === ".js"; + }) + .forEach(function (file) { + mocha.addFile(path.join(testDir, file)); + }); +}); + +mocha.run(function (failures) { + process.exitCode = failures ? 1 : 0; +}); diff --git a/docs/docs/js.md b/docs/docs/js.md index 28297aac7..37b0f92f1 100644 --- a/docs/docs/js.md +++ b/docs/docs/js.md @@ -66,7 +66,7 @@ stylus(str) }); ``` -## .define(name, node) +## .define(name, node[, raw]) By passing a `Node`, we may define a global variable. This is useful when exposing conditional features within your library depending on the availability of another. For example the **Nib** extension library conditionally supports node-canvas, providing image generation. @@ -89,6 +89,8 @@ Stylus also casts JavaScript values to their Stylus equivalents when possible. H .define('families', ['Helvetica Neue', 'Helvetica', 'sans-serif']) ``` +Note: In default, The JavaScript object variable will coerce to a tuple-array-like expression. For example `{ foo: 'bar', bar: 'baz' }` would become the expression `(foo 'bar') (bar 'baz')`. If you want to get a [hash object](https://stylus-lang.com/docs/hashes.html) return, please set `raw` to `true`. + These same rules apply to return values in js functions as well: ```js diff --git a/docs/index.md b/docs/index.md index f36c944b5..e7f62695b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,12 +3,12 @@ layout: home sidebar: false title: Stylus -titleTemplate: An expressive, robust, feature-rich CSS language built for nodejs +titleTemplate: An expressive, robust, feature-rich CSS language built for Node.js hero: name: Stylus - text: Expressive, dynamic and robust CSSs - tagline: An expressive, robust, feature-rich CSS language built for nodejs + text: Expressive, dynamic, and robust CSS + tagline: An expressive, robust, feature-rich CSS language built for Node.js image: src: /logo.svg alt: Stylus @@ -27,12 +27,12 @@ hero: link: https://github.com/stylus/stylus features: - - title: Born for Nodejs - details: TJ create this project for nodejs ecosystem since 2010 + - title: Born for Node.js + details: TJ created this project for the Node.js Ecosystem in 2010 - title: CSS Compatible - details: Don't like indented syntax ? ok, it's optional! You can write stylus like css-style without pain + details: Don't like indented syntax? OK, it's optional! You can write Stylus like CSS without the pain - title: IDE support - details: Both VSCode (with stylus extension) and WebStorm (builtin) support stylus development + details: Both VSCode (with Stylus extension) and WebStorm (built in) support Stylus development - title: All optional - details: braces, semi-colons and more can be omit in your code, keep clean and less + details: Braces, semi-colons, and more can be omitted from your code to keep it clean and smaller --- diff --git a/docs/package-lock.json b/docs/package-lock.json index 83469b4d1..0514a0ba1 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -2200,6 +2200,15 @@ "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", "dev": true }, + "busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dev": true, + "requires": { + "streamsearch": "^1.1.0" + } + }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -3572,9 +3581,9 @@ "dev": true }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, "jsonc-parser": { @@ -4419,6 +4428,12 @@ "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", "dev": true }, + "streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "dev": true + }, "string.prototype.matchall": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz", @@ -4634,10 +4649,13 @@ } }, "undici": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.10.0.tgz", - "integrity": "sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==", - "dev": true + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.19.1.tgz", + "integrity": "sha512-YiZ61LPIgY73E7syxCDxxa3LV2yl3sN8spnIuTct60boiiRaE1J8mNWHO8Im2Zi/sFrPusjLlmRPrsyraSqX6A==", + "dev": true, + "requires": { + "busboy": "^1.6.0" + } }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", @@ -4800,9 +4818,9 @@ "dev": true }, "vite": { - "version": "2.9.15", - "resolved": "https://registry.npmjs.org/vite/-/vite-2.9.15.tgz", - "integrity": "sha512-fzMt2jK4vQ3yK56te3Kqpkaeq9DkcZfBbzHwYpobasvgYmP2SoAr6Aic05CsB4CzCZbsDv4sujX3pkEGhLabVQ==", + "version": "2.9.16", + "resolved": "https://registry.npmjs.org/vite/-/vite-2.9.16.tgz", + "integrity": "sha512-X+6q8KPyeuBvTQV8AVSnKDvXoBMnTx8zxh54sOwmmuOdxkjMmEJXH2UEchA+vTMps1xw9vL64uwJOWryULg7nA==", "dev": true, "requires": { "esbuild": "^0.14.27", diff --git a/lib/errors.js b/lib/errors.js index 7fa9a3506..5f8c5aa54 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -31,7 +31,7 @@ function ParseError(msg) { * Inherit from `Error.prototype`. */ -ParseError.prototype.__proto__ = Error.prototype; +Object.setPrototypeOf(ParseError.prototype, Error.prototype); /** * Initialize a new `SyntaxError` with the given `msg`. @@ -52,4 +52,4 @@ function SyntaxError(msg) { * Inherit from `Error.prototype`. */ -SyntaxError.prototype.__proto__ = Error.prototype; +Object.setPrototypeOf(SyntaxError.prototype, Error.prototype); diff --git a/lib/nodes/arguments.js b/lib/nodes/arguments.js index c774a6fe4..757b6bfc6 100644 --- a/lib/nodes/arguments.js +++ b/lib/nodes/arguments.js @@ -26,7 +26,7 @@ var Arguments = module.exports = function Arguments(){ * Inherit from `nodes.Expression.prototype`. */ -Arguments.prototype.__proto__ = nodes.Expression.prototype; +Object.setPrototypeOf(Arguments.prototype, nodes.Expression.prototype); /** * Initialize an `Arguments` object with the nodes diff --git a/lib/nodes/atblock.js b/lib/nodes/atblock.js index 03a191cf2..07a6406b1 100644 --- a/lib/nodes/atblock.js +++ b/lib/nodes/atblock.js @@ -32,7 +32,7 @@ Atblock.prototype.__defineGetter__('nodes', function(){ * Inherit from `Node.prototype`. */ -Atblock.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Atblock.prototype, Node.prototype); /** * Return a clone of this node. diff --git a/lib/nodes/atrule.js b/lib/nodes/atrule.js index 43301b500..d51e86f41 100644 --- a/lib/nodes/atrule.js +++ b/lib/nodes/atrule.js @@ -26,7 +26,7 @@ var Atrule = module.exports = function Atrule(type){ * Inherit from `Node.prototype`. */ -Atrule.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Atrule.prototype, Node.prototype); /** * Check if at-rule's block has only properties. diff --git a/lib/nodes/binop.js b/lib/nodes/binop.js index c56aee398..e61343f53 100644 --- a/lib/nodes/binop.js +++ b/lib/nodes/binop.js @@ -31,11 +31,11 @@ var BinOp = module.exports = function BinOp(op, left, right){ * Inherit from `Node.prototype`. */ -BinOp.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(BinOp.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/block.js b/lib/nodes/block.js index b80af817b..766999c37 100644 --- a/lib/nodes/block.js +++ b/lib/nodes/block.js @@ -30,7 +30,7 @@ var Block = module.exports = function Block(parent, node){ * Inherit from `Node.prototype`. */ -Block.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Block.prototype, Node.prototype); /** * Check if this block has properties.. @@ -77,7 +77,7 @@ Block.prototype.__defineGetter__('isEmpty', function(){ /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/boolean.js b/lib/nodes/boolean.js index 97c11971b..dfd691ac6 100644 --- a/lib/nodes/boolean.js +++ b/lib/nodes/boolean.js @@ -24,7 +24,7 @@ var Boolean = module.exports = function Boolean(val){ if (this.nodeName) { this.val = !!val; } else { - return new Boolean(val); + return new Boolean(!!val); } }; @@ -32,7 +32,7 @@ var Boolean = module.exports = function Boolean(val){ * Inherit from `Node.prototype`. */ -Boolean.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Boolean.prototype, Node.prototype); /** * Return `this` node. diff --git a/lib/nodes/call.js b/lib/nodes/call.js index 5cf655df3..5b9e7a05f 100644 --- a/lib/nodes/call.js +++ b/lib/nodes/call.js @@ -29,11 +29,11 @@ var Call = module.exports = function Call(name, args){ * Inherit from `Node.prototype`. */ -Call.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Call.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/charset.js b/lib/nodes/charset.js index e6d520771..86b4b2511 100644 --- a/lib/nodes/charset.js +++ b/lib/nodes/charset.js @@ -27,7 +27,7 @@ var Charset = module.exports = function Charset(val){ * Inherit from `Node.prototype`. */ -Charset.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Charset.prototype, Node.prototype); /** * Return @charset "val". diff --git a/lib/nodes/comment.js b/lib/nodes/comment.js index 56b59b3bf..520a2ca47 100644 --- a/lib/nodes/comment.js +++ b/lib/nodes/comment.js @@ -31,7 +31,7 @@ var Comment = module.exports = function Comment(str, suppress, inline){ * Inherit from `Node.prototype`. */ -Comment.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Comment.prototype, Node.prototype); /** * Return a JSON representation of this node. diff --git a/lib/nodes/each.js b/lib/nodes/each.js index 985bd29da..2c8e5c02d 100644 --- a/lib/nodes/each.js +++ b/lib/nodes/each.js @@ -35,11 +35,11 @@ var Each = module.exports = function Each(val, key, expr, block){ * Inherit from `Node.prototype`. */ -Each.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Each.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/expression.js b/lib/nodes/expression.js index 92293f32f..fa4cac68d 100644 --- a/lib/nodes/expression.js +++ b/lib/nodes/expression.js @@ -67,11 +67,11 @@ Expression.prototype.__defineGetter__('hash', function(){ * Inherit from `Node.prototype`. */ -Expression.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Expression.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/extend.js b/lib/nodes/extend.js index 05458b612..52c2f5a47 100644 --- a/lib/nodes/extend.js +++ b/lib/nodes/extend.js @@ -27,11 +27,11 @@ var Extend = module.exports = function Extend(selectors){ * Inherit from `Node.prototype`. */ -Extend.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Extend.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/feature.js b/lib/nodes/feature.js index f4e183282..d15ac59e5 100644 --- a/lib/nodes/feature.js +++ b/lib/nodes/feature.js @@ -28,11 +28,11 @@ var Feature = module.exports = function Feature(segs){ * Inherit from `Node.prototype`. */ -Feature.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Feature.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/function.js b/lib/nodes/function.js index 25a6586bc..f5149587c 100644 --- a/lib/nodes/function.js +++ b/lib/nodes/function.js @@ -43,7 +43,7 @@ Function.prototype.__defineGetter__('arity', function(){ * Inherit from `Node.prototype`. */ -Function.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Function.prototype, Node.prototype); /** * Return hash. @@ -58,7 +58,7 @@ Function.prototype.__defineGetter__('hash', function(){ /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/group.js b/lib/nodes/group.js index 8c1a4ea35..37430cd25 100644 --- a/lib/nodes/group.js +++ b/lib/nodes/group.js @@ -27,7 +27,7 @@ var Group = module.exports = function Group(){ * Inherit from `Node.prototype`. */ -Group.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Group.prototype, Node.prototype); /** * Push the given `selector` node. @@ -74,7 +74,7 @@ Group.prototype.__defineGetter__('hasOnlyPlaceholders', function(){ /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/hsla.js b/lib/nodes/hsla.js index bea1e1249..f7870e45a 100644 --- a/lib/nodes/hsla.js +++ b/lib/nodes/hsla.js @@ -35,7 +35,7 @@ var HSLA = exports = module.exports = function HSLA(h,s,l,a){ * Inherit from `Node.prototype`. */ -HSLA.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(HSLA.prototype, Node.prototype); /** * Return hsla(n,n,n,n). @@ -54,7 +54,7 @@ HSLA.prototype.toString = function(){ /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/ident.js b/lib/nodes/ident.js index 181f738aa..f56ab7bc7 100644 --- a/lib/nodes/ident.js +++ b/lib/nodes/ident.js @@ -54,11 +54,11 @@ Ident.prototype.__defineGetter__('hash', function(){ * Inherit from `Node.prototype`. */ -Ident.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Ident.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/if.js b/lib/nodes/if.js index e7d354d2b..8af906911 100644 --- a/lib/nodes/if.js +++ b/lib/nodes/if.js @@ -34,11 +34,11 @@ var If = module.exports = function If(cond, negate){ * Inherit from `Node.prototype`. */ -If.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(If.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/import.js b/lib/nodes/import.js index 7a3548a4b..c8e41dbaf 100644 --- a/lib/nodes/import.js +++ b/lib/nodes/import.js @@ -28,7 +28,7 @@ var Import = module.exports = function Import(expr, once){ * Inherit from `Node.prototype`. */ -Import.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Import.prototype, Node.prototype); /** * Return a clone of this node. diff --git a/lib/nodes/keyframes.js b/lib/nodes/keyframes.js index e4e1271a7..70201725e 100644 --- a/lib/nodes/keyframes.js +++ b/lib/nodes/keyframes.js @@ -30,11 +30,11 @@ var Keyframes = module.exports = function Keyframes(segs, prefix){ * Inherit from `Atrule.prototype`. */ -Keyframes.prototype.__proto__ = Atrule.prototype; +Object.setPrototypeOf(Keyframes.prototype, Atrule.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/literal.js b/lib/nodes/literal.js index 9c6e86653..f553f3740 100644 --- a/lib/nodes/literal.js +++ b/lib/nodes/literal.js @@ -30,7 +30,7 @@ var Literal = module.exports = function Literal(str){ * Inherit from `Node.prototype`. */ -Literal.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Literal.prototype, Node.prototype); /** * Return hash. diff --git a/lib/nodes/media.js b/lib/nodes/media.js index 65fdf7ba4..c81f9af69 100644 --- a/lib/nodes/media.js +++ b/lib/nodes/media.js @@ -27,7 +27,7 @@ var Media = module.exports = function Media(val){ * Inherit from `Atrule.prototype`. */ -Media.prototype.__proto__ = Atrule.prototype; +Object.setPrototypeOf(Media.prototype, Atrule.prototype); /** * Clone this node. diff --git a/lib/nodes/member.js b/lib/nodes/member.js index af947388f..5249b84f0 100644 --- a/lib/nodes/member.js +++ b/lib/nodes/member.js @@ -29,7 +29,7 @@ var Member = module.exports = function Member(left, right){ * Inherit from `Node.prototype`. */ -Member.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Member.prototype, Node.prototype); /** * Return a clone of this node. diff --git a/lib/nodes/namespace.js b/lib/nodes/namespace.js index 878b474ec..f9276cf6e 100644 --- a/lib/nodes/namespace.js +++ b/lib/nodes/namespace.js @@ -28,7 +28,7 @@ var Namespace = module.exports = function Namespace(val, prefix){ * Inherit from `Node.prototype`. */ -Namespace.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Namespace.prototype, Node.prototype); /** * Return @namespace "val". diff --git a/lib/nodes/node.js b/lib/nodes/node.js index 6466177f7..6aa1281f4 100644 --- a/lib/nodes/node.js +++ b/lib/nodes/node.js @@ -32,7 +32,7 @@ function CoercionError(msg) { * Inherit from `Error.prototype`. */ -CoercionError.prototype.__proto__ = Error.prototype; +Object.setPrototypeOf(CoercionError.prototype, Error.prototype); /** * Node constructor. @@ -84,7 +84,7 @@ Node.prototype = { /** * Return this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/null.js b/lib/nodes/null.js index 4efea99f0..ace0f1323 100644 --- a/lib/nodes/null.js +++ b/lib/nodes/null.js @@ -24,7 +24,7 @@ var Null = module.exports = function Null(){}; * Inherit from `Node.prototype`. */ -Null.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Null.prototype, Node.prototype); /** * Return 'Null'. @@ -33,7 +33,7 @@ Null.prototype.__proto__ = Node.prototype; * @api public */ -Null.prototype.inspect = +Null.prototype.inspect = Null.prototype.toString = function(){ return 'null'; }; diff --git a/lib/nodes/object.js b/lib/nodes/object.js index ed093d8d2..651e13a46 100644 --- a/lib/nodes/object.js +++ b/lib/nodes/object.js @@ -29,7 +29,7 @@ var Object = module.exports = function Object(){ * Inherit from `Node.prototype`. */ -Object.prototype.__proto__ = Node.prototype; +(global || globalThis).Object.setPrototypeOf(Object.prototype, Node.prototype); /** * Set `key` to `val`. diff --git a/lib/nodes/params.js b/lib/nodes/params.js index d7ac6d744..6860c0e47 100644 --- a/lib/nodes/params.js +++ b/lib/nodes/params.js @@ -40,7 +40,7 @@ Params.prototype.__defineGetter__('length', function(){ * Inherit from `Node.prototype`. */ -Params.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Params.prototype, Node.prototype); /** * Push the given `node`. @@ -55,7 +55,7 @@ Params.prototype.push = function(node){ /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/property.js b/lib/nodes/property.js index 215785ac3..80f38f404 100644 --- a/lib/nodes/property.js +++ b/lib/nodes/property.js @@ -29,11 +29,11 @@ var Property = module.exports = function Property(segs, expr){ * Inherit from `Node.prototype`. */ -Property.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Property.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/query-list.js b/lib/nodes/query-list.js index 3819640b4..936919694 100644 --- a/lib/nodes/query-list.js +++ b/lib/nodes/query-list.js @@ -26,11 +26,11 @@ var QueryList = module.exports = function QueryList(){ * Inherit from `Node.prototype`. */ -QueryList.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(QueryList.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/query.js b/lib/nodes/query.js index 47a568b71..ecf5a498c 100644 --- a/lib/nodes/query.js +++ b/lib/nodes/query.js @@ -28,11 +28,11 @@ var Query = module.exports = function Query(){ * Inherit from `Node.prototype`. */ -Query.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Query.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/return.js b/lib/nodes/return.js index 003ef3801..7da671485 100644 --- a/lib/nodes/return.js +++ b/lib/nodes/return.js @@ -27,11 +27,11 @@ var Return = module.exports = function Return(expr){ * Inherit from `Node.prototype`. */ -Return.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Return.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/rgba.js b/lib/nodes/rgba.js index a961dc9cd..d76f0c56a 100644 --- a/lib/nodes/rgba.js +++ b/lib/nodes/rgba.js @@ -39,11 +39,11 @@ var RGBA = exports = module.exports = function RGBA(r,g,b,a){ * Inherit from `Node.prototype`. */ -RGBA.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(RGBA.prototype, Node.prototype); /** * Return an `RGBA` without clamping values. - * + * * @param {Number} r * @param {Number} g * @param {Number} b @@ -63,7 +63,7 @@ RGBA.withoutClamping = function(r,g,b,a){ /** * Return a clone of this node. - * + * * @return {Node} * @api public */ @@ -188,7 +188,7 @@ RGBA.prototype.multiply = function(n){ this.r * n , this.g * n , this.b * n - , this.a); + , this.a); }; /** @@ -204,7 +204,7 @@ RGBA.prototype.divide = function(n){ this.r / n , this.g / n , this.b / n - , this.a); + , this.a); }; /** @@ -338,7 +338,7 @@ exports.fromHSLA = function(hsla){ if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6; return m1; } - + return new RGBA(r,g,b,a); }; diff --git a/lib/nodes/root.js b/lib/nodes/root.js index 3bfb3c218..3e42e7c53 100644 --- a/lib/nodes/root.js +++ b/lib/nodes/root.js @@ -25,7 +25,7 @@ var Root = module.exports = function Root(){ * Inherit from `Node.prototype`. */ -Root.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Root.prototype, Node.prototype); /** * Push a `node` to this block. diff --git a/lib/nodes/selector.js b/lib/nodes/selector.js index db183cc7f..8b2b61db1 100644 --- a/lib/nodes/selector.js +++ b/lib/nodes/selector.js @@ -30,7 +30,7 @@ var Selector = module.exports = function Selector(segs){ * Inherit from `Node.prototype`. */ -Selector.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Selector.prototype, Node.prototype); /** * Return the selector string. @@ -56,7 +56,7 @@ Selector.prototype.__defineGetter__('isPlaceholder', function(){ /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/string.js b/lib/nodes/string.js index 1fd2b4504..c0dd8785d 100644 --- a/lib/nodes/string.js +++ b/lib/nodes/string.js @@ -37,7 +37,7 @@ var String = module.exports = function String(val, quote){ * Inherit from `Node.prototype`. */ -String.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(String.prototype, Node.prototype); /** * Return quoted string. @@ -52,7 +52,7 @@ String.prototype.toString = function(){ /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/supports.js b/lib/nodes/supports.js index ab0587837..a3dbf8390 100644 --- a/lib/nodes/supports.js +++ b/lib/nodes/supports.js @@ -26,7 +26,7 @@ var Supports = module.exports = function Supports(condition){ * Inherit from `Atrule.prototype`. */ -Supports.prototype.__proto__ = Atrule.prototype; +Object.setPrototypeOf(Supports.prototype, Atrule.prototype); /** * Return a clone of this node. diff --git a/lib/nodes/ternary.js b/lib/nodes/ternary.js index 2034170a4..16e0b10d0 100644 --- a/lib/nodes/ternary.js +++ b/lib/nodes/ternary.js @@ -31,11 +31,11 @@ var Ternary = module.exports = function Ternary(cond, trueExpr, falseExpr){ * Inherit from `Node.prototype`. */ -Ternary.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Ternary.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/unaryop.js b/lib/nodes/unaryop.js index 6ac92ab34..6cfb44c12 100644 --- a/lib/nodes/unaryop.js +++ b/lib/nodes/unaryop.js @@ -29,11 +29,11 @@ var UnaryOp = module.exports = function UnaryOp(op, expr){ * Inherit from `Node.prototype`. */ -UnaryOp.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(UnaryOp.prototype, Node.prototype); /** * Return a clone of this node. - * + * * @return {Node} * @api public */ diff --git a/lib/nodes/unit.js b/lib/nodes/unit.js index 2d38d84fa..aae54ab75 100644 --- a/lib/nodes/unit.js +++ b/lib/nodes/unit.js @@ -46,7 +46,7 @@ var Unit = module.exports = function Unit(val, type){ * Inherit from `Node.prototype`. */ -Unit.prototype.__proto__ = Node.prototype; +Object.setPrototypeOf(Unit.prototype, Node.prototype); /** * Return Boolean based on the unit value. diff --git a/lib/renderer.js b/lib/renderer.js index dd478b3fb..eb3f9407f 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -51,7 +51,7 @@ function Renderer(str, options) { * Inherit from `EventEmitter.prototype`. */ -Renderer.prototype.__proto__ = EventEmitter.prototype; +Object.setPrototypeOf(Renderer.prototype, EventEmitter.prototype); /** * Expose events explicitly. diff --git a/lib/stack/index.js b/lib/stack/index.js index 9e288c62f..f8de9d0fb 100644 --- a/lib/stack/index.js +++ b/lib/stack/index.js @@ -19,7 +19,7 @@ var Stack = module.exports = function Stack() { * Inherit from `Array.prototype`. */ -Stack.prototype.__proto__ = Array.prototype; +Object.setPrototypeOf(Stack.prototype, Array.prototype); /** * Push the given `frame`. diff --git a/lib/units.js b/lib/units.js index b26bb9842..a242a7b83 100644 --- a/lib/units.js +++ b/lib/units.js @@ -6,10 +6,18 @@ */ // units found in http://www.w3.org/TR/css3-values +// and in https://www.w3.org/TR/css-values-4 module.exports = [ 'em', 'ex', 'ch', 'rem' // relative lengths - , 'vw', 'vh', 'vmin', 'vmax' // relative viewport-percentage lengths + + , 'vw', 'svw', 'lvw', 'dvw' // relative viewport-percentage lengths (including de-facto standard) + , 'vh', 'svh', 'lvh', 'dvh' + , 'vi', 'svi', 'lvi', 'dvi' + , 'vb', 'svb', 'lvb', 'dvb' + , 'vmin', 'svmin', 'lvmin', 'dvmin' + , 'vmax', 'svmax', 'lvmax', 'dvmax' + , 'cm', 'mm', 'in', 'pt', 'pc', 'px' // absolute lengths , 'deg', 'grad', 'rad', 'turn' // angles , 's', 'ms' // times diff --git a/lib/visitor/compiler.js b/lib/visitor/compiler.js index 9a793339e..f4ef4a60e 100644 --- a/lib/visitor/compiler.js +++ b/lib/visitor/compiler.js @@ -39,7 +39,7 @@ var Compiler = module.exports = function Compiler(root, options) { * Inherit from `Visitor.prototype`. */ -Compiler.prototype.__proto__ = Visitor.prototype; +Object.setPrototypeOf(Compiler.prototype, Visitor.prototype); /** * Compile to css, and return a string of CSS. diff --git a/lib/visitor/deps-resolver.js b/lib/visitor/deps-resolver.js index 94827db9c..1f2fd3089 100644 --- a/lib/visitor/deps-resolver.js +++ b/lib/visitor/deps-resolver.js @@ -33,7 +33,7 @@ var DepsResolver = module.exports = function DepsResolver(root, options) { * Inherit from `Visitor.prototype`. */ -DepsResolver.prototype.__proto__ = Visitor.prototype; +Object.setPrototypeOf(DepsResolver.prototype, Visitor.prototype); var visit = DepsResolver.prototype.visit; diff --git a/lib/visitor/evaluator.js b/lib/visitor/evaluator.js index d60ddfcad..4aa8cf6be 100644 --- a/lib/visitor/evaluator.js +++ b/lib/visitor/evaluator.js @@ -144,7 +144,7 @@ var Evaluator = module.exports = function Evaluator(root, options) { * Inherit from `Visitor.prototype`. */ -Evaluator.prototype.__proto__ = Visitor.prototype; +Object.setPrototypeOf(Evaluator.prototype, Visitor.prototype); /** * Proxy visit to expose node line numbers. @@ -913,7 +913,7 @@ Evaluator.prototype.visitImport = function(imported){ // Throw if import failed if (!found) throw new Error('failed to locate @' + nodeName + ' file ' + path); - + var block = new nodes.Block; for (var i = 0, len = found.length; i < len; ++i) { diff --git a/lib/visitor/normalizer.js b/lib/visitor/normalizer.js index 215e6f3c5..6760c9427 100644 --- a/lib/visitor/normalizer.js +++ b/lib/visitor/normalizer.js @@ -40,7 +40,7 @@ var Normalizer = module.exports = function Normalizer(root, options) { * Inherit from `Visitor.prototype`. */ -Normalizer.prototype.__proto__ = Visitor.prototype; +Object.setPrototypeOf(Normalizer.prototype, Visitor.prototype); /** * Normalize the node tree. @@ -440,4 +440,4 @@ Normalizer.prototype._checkForPrefixedGroups = function (selector) { break; } return result; -}; \ No newline at end of file +}; diff --git a/lib/visitor/sourcemapper.js b/lib/visitor/sourcemapper.js index 0e081104d..97e998884 100644 --- a/lib/visitor/sourcemapper.js +++ b/lib/visitor/sourcemapper.js @@ -58,7 +58,7 @@ var SourceMapper = module.exports = function SourceMapper(root, options){ * Inherit from `Compiler.prototype`. */ -SourceMapper.prototype.__proto__ = Compiler.prototype; +Object.setPrototypeOf(SourceMapper.prototype, Compiler.prototype); /** * Generate and write source map. diff --git a/package.json b/package.json index baef1a669..6480ec082 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,11 @@ }, "scripts": { "prepublish": "npm prune", - "test": "mocha test/ test/middleware/ --require chai --bail --check-leaks --reporter dot" + "test": "mocha test/ test/middleware/ --require chai --bail --check-leaks --reporter dot", + "test:deno": "deno run -A deno/test.ts" }, "dependencies": { - "@adobe/css-tools": "^4.0.1", + "@adobe/css-tools": "~4.2.0", "debug": "^4.3.2", "glob": "^7.1.6", "sax": "~1.2.4",