114 Commits
Author SHA1 Message Date
Andrey Sitnik 69d5b399fd Fix Maximum call stack size exceeded error 2026-07-11 19:06:38 +00:00
Andrey Sitnik 62ad57f190 Prevent prototype hijacking in fromJSON 2026-07-11 16:44:46 +00:00
Mahin AnowarandGitHub 9e1092edf0 Don't clone root-less child nodes in container constructor (#2097)
The container constructor cloned every real Node passed in `nodes`, so a
freshly created (parent-less) node was adopted as a copy and the caller's
original reference never had its `parent` set — later operating on it threw
`Cannot read properties of undefined`. The clone was added only to keep the
source tree intact when moving nodes between roots, so it's skipped when the
node has no parent. Nodes that already belong to another tree are still
cloned, preserving the existing behavior. Closes #1987.
2026-06-28 16:50:07 +02:00
Sarath FrancisandGitHub aeeb3006c0 Fix Node#rangeBy() ignoring index 0 (#2091)
When calling Node#rangeBy() (and therefore Node#error() and
Node#warn()) with index 0, the resulting range covered the whole node
instead of a single character at offset 0.

The end-of-range branch used a truthy check on opts.index, so an index
of 0 fell through and left the end position at the node's end. This is
the same off-by-zero issue that was previously fixed for endIndex; the
index branches were missed. Switch both index checks to a numeric type
check, matching the existing endIndex handling.

index 0 now produces a single-character range, consistent with every
other index value.
2026-06-27 15:48:04 +02:00
74d18036e9 fix(node): always include offset in positionBy() like rangeBy() (#2099)
positionBy()'s default branch returned this.source.start verbatim, so for
custom syntaxes whose source.start lacks an offset (e.g. postcss-html) it
returned a position without offset, violating the Position type which
declares offset as required. rangeBy()/positionInside() were normalized to
always compute offset via sourceOffset() (#2033, issue #2029) but
positionBy() was left behind. Mirror the rangeBy() pattern.

Co-authored-by: oss69U-prep <prep@local>

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-27 15:31:28 +02:00
Andrey Sitnik 341e0f132f Fix code format 2025-05-29 13:46:23 +09:00
git-sumitchaudharyandGitHub 9d52a82ef5 fixed error at line 401 (#2046)
when using postcss using parcel 
an error was occuring due to  no check mentioned for value at line 401 , which caused error while reading value when it was undefined
hence i added a check if its value is undefined continue and dont move forward
2025-05-29 06:41:11 +02:00
b38a1162f1 Fix missing offset in Node#positionInside, Node#positionBy and Node#rangeBy (#2033)
* Fix `opts` argument cannot be omitted

* Assign default values to `opts` just in case

- The `opts` argument to `Node#error` is currently omissible, but we'll assign a default value just in case.

* Add test cases

* Add test cases for `Node#rangeBy({start, end})`

* Add test cases for offset

* Fix missing offset in `Node#positionInside`, `Node#positionBy` and `Node#rangeBy`

* Fix conflict resolution mistakes

---------

Co-authored-by: Andrey Sitnik <[email protected]>
2025-03-22 18:07:03 +01:00
mizdraandGitHub a9a4e8849a Fix opts argument of Node#rangeBy() and Node#positionBy() cannot be omitted (#2031)
* Fix `opts` argument cannot be omitted

* Assign default values to `opts` just in case

- The `opts` argument to `Node#error` is currently omissible, but we'll assign a default value just in case.

* Add test cases
2025-03-22 17:13:46 +01:00
Andrey Sitnik d3d4d735df Update ESLint config 2025-02-19 13:43:47 +00:00
Romain MenkeandGitHub 4a7f5d0b05 Improve backwards compat for Input#document (#2000) 2025-01-14 11:53:43 +01:00
2f3c759a4b Add Input#document (#1996)
* Add `Input#document`

* Update lib/postcss.d.ts

Co-authored-by: Andrey Sitnik <[email protected]>

* apply suggestion from code review

---------

Co-authored-by: Andrey Sitnik <[email protected]>
2025-01-13 16:12:42 +01:00
Romain MenkeandGitHub 97e48f613e Fix position calculations when offset is missing (#1983) 2024-11-11 20:55:58 +01:00
Romain MenkeandGitHub b3f6e2737f fix inconsistent position calculations (#1980) 2024-11-10 22:13:31 +01:00
Andrey Sitnik 9d4c3010d0 Try to fix CI 2024-09-02 10:25:53 +02:00
Andrey Sitnik 19afb318d6 Sort source code and fix ESLint 2024-08-31 23:26:27 +02:00
Natalie Weizenbaum 10ac71fb4c Add a protected markDirty() method on Node
This is useful to call from subtypes.
2024-08-08 22:39:16 -07:00
Romain Menke 4baa41af52 fix endIndex 2024-03-20 18:28:20 +01:00
Andrey Sitnik 584d6a8a91 Update linter 2023-09-18 23:22:49 +02:00
Andrey Sitnik 89b7f7ac78 Update dependencies and code style 2023-07-06 13:38:48 +02:00
Romain Menke d0ae2204f0 reduce calls to Node.prototype.toString() 2023-07-02 11:37:12 +02:00
Adaline Valentina Simonian 4e46d40731 Merge branch 'main' into fix-ranges 2021-11-21 11:13:39 -08:00
Adaline Valentina Simonian ba57fdd2ae fix: handle case when node end is undefined 2021-11-19 12:10:34 -08:00
Adaline Valentina Simonian f1fa07d292 refactor: make suggested changes 2021-11-18 16:56:31 -08:00
Adaline Valentina Simonian ae0c99b082 fix: use correct positions for ranges 2021-11-17 16:37:23 -08:00
Andrey Kim afe45db6e8 Merge branch 'main' of https://github.com/postcss/postcss into main 2021-11-17 23:55:23 +03:00
Adaline Valentina Simonian 45097948ff feat: Support ranges for errors and warnings
Allows for better diagnostics in linters, language servers, and plugins.
2021-11-16 17:15:01 -08:00
Andrey Kim c5059e1501 Convert istanbul ignores to c8 2021-11-15 23:10:13 +03:00
Andrey Sitnik a3b6886f68 Fix Node[my] hack 2021-06-14 09:23:43 -04:00
Andrey SitnikandGitHub 2c6777648a Merge pull request #1582 from hudochenkov/add-document-node-1498
Add Document node and related API (#1498)
2021-05-18 20:46:25 -04:00
Aleks Hudochenkov bd17ae8ec9 Remove Node#document() 2021-05-18 02:01:20 +02:00
Jonathan NealandAndrey Sitnik f070b51ff1 feat: Node#assign
The `assign` function lets authors assign multiple properties to a node from a single object.

This can improve code clarity when updating multiple properties while offering a helpful typing experience.
2021-05-17 08:50:29 -04:00
Aleks Hudochenkov 430ee0d902 Add Document node and related API (#1498) 2021-05-16 20:15:56 +02:00
Andrey Sitnik 843ab11b6e Add Prettier 2021-03-11 19:11:37 -05:00
Andrey Sitnik 4d9a51a72b Fix Node#toJSON and proxyCache 2021-02-10 13:33:59 -05:00
Niklas Mischkulnig b3405e610c Fix JSON.stringify of an array of nodes 2021-01-07 12:04:45 +01:00
Niklas Mischkulnig e22b4711d4 Fix test/don't remove source.end 2020-12-09 12:31:53 +01:00
Niklas Mischkulnig 1142d0f544 Rename to input/inputId 2020-12-09 12:31:53 +01:00
Niklas Mischkulnig bf6ce4b9fb Deduplicate Input objects in JSON 2020-12-09 12:31:53 +01:00
Niklas Mischkulnig fd91269044 All nodes have a source property, not just Root 2020-12-09 12:31:53 +01:00
Niklas Mischkulnig ec69e352d9 fromJSON and toJSON 2020-12-05 00:15:24 +01:00
Remco Haszing b94a22e19f Fix usage of default exports with TypeScript
This is done by assigning the property `default` for all properties that are
exported using `export default` according to their type definitions.

Closes #1424
2020-11-10 14:24:37 +01:00
Andrey Sitnik c20d10df29 Fix visiting parent on nested children changes 2020-09-23 18:47:27 -04:00
Andrey Sitnik 8f8bfe31d7 Fix child adding methods in Container 2020-09-20 12:47:05 -04:00
Andrey Sitnik 0048657b13 Add "use strict" because it may effect on tokenizer performance 2020-09-08 01:46:46 -04:00
Andrey Sitnik 887783b405 Change plugin running code and mark moved nodes as dirty 2020-09-05 00:31:30 -04:00
Andrey Sitnik 1ae90b7f70 Speed up PostCSS 2020-09-02 22:17:01 -04:00
Andrey Sitnik 15d0f4b7e4 Speed up async visitor API 2020-09-01 00:12:25 -04:00
Andrey Sitnik 6df84fce5e Fix two args walk methods in proxies 2020-08-24 21:24:28 -05:00
Andrey Sitnik 8b5c41e777 Prevent loop with visitor API 2020-08-22 14:56:49 -05:00