lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Alow manipulating `Selector` parts from consumer code

Open phoenix-ru opened this issue 2 years ago • 0 comments
trafficstars

This PR needs a review and is open to renaming/tests/suggestions.

The proposed API is a logical continuation of https://github.com/parcel-bundler/lightningcss/issues/495, https://github.com/parcel-bundler/lightningcss/pull/485, and it covers a usecase of fervid project: https://github.com/phoenix-ru/fervid/blob/master/crates/fervid_css/src/transform_style_scoped.rs#L331-L337

It allows appending Selector components with bypassing the checks in https://github.com/parcel-bundler/lightningcss/blob/master/selectors/parser.rs#L718-L725

Two new helpers are added:

  • insert_raw for inserting a single Component at an arbitrary index;
  • insert_raw_multiple for inserting multiple Components at an arbitrary index.

It is a blocker to Vue <style> transformations, examples of which are here: https://github.com/phoenix-ru/fervid/blob/master/crates/fervid_css/src/lib.rs#L92-L186

phoenix-ru avatar Aug 14 '23 15:08 phoenix-ru