Skip to content

Add Input#document - #1996

Merged
ai merged 3 commits into
postcss:mainfrom
romainmenke:input.document--exuberant-piranha-0b3a5fbff6
Jan 13, 2025
Merged

ai merged 3 commits into
postcss:mainfrom
romainmenke:input.document--exuberant-piranha-0b3a5fbff6

Conversation

@romainmenke

Copy link
Copy Markdown
Contributor

fixes: #1995

Comment thread lib/input.js
}

this.document = this.css
if (opts.document) this.document = opts.document.toString()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to use opts.document and add document to ProcessOptions.

Alternatively it could also be less exposed and only exists as a field on Input.

let root = parse('a {} b {}')
root.source.input.document = '<style>a {} b {}</style>';

We would still keep this.document = this.css to make sure that there is always a value.

@romainmenke
romainmenke marked this pull request as ready for review December 25, 2024 11:28
Comment thread lib/input.d.ts Outdated
* Input source with support for non-CSS documents.
*
* ```js
* const input = postcss.parse('a{}', { from: file }).input

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s use HTML in example to show why we need document

Comment thread lib/postcss.d.ts Resolved
@ai

ai commented Dec 25, 2024

Copy link
Copy Markdown
Member

Looks amazing (only a few small docs changes suggested), but I prefer to merge and release it after holidays to avoid rush fixes in the middle of holiday :D

@romainmenke

Copy link
Copy Markdown
Contributor Author

Thank you for the review 🙇
Yes, let's wait a bit before merging and releasing :)

@ai

ai commented Jan 13, 2025

Copy link
Copy Markdown
Member

Thanks! The new property was released in 8.5.0.

@romainmenke

Copy link
Copy Markdown
Contributor Author

Thank you @ai for the reviews and release 🙇

hanzo-dev pushed a commit to hanzoai/postcss that referenced this pull request Sep 9, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syntaxes like postcss-html adjust node source locations relative to enclosing non-css documents

2 participants