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.
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.
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]>
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
* 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]>
* 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
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.
This is done by assigning the property `default` for all properties that are
exported using `export default` according to their type definitions.
Closes#1424