Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Input#document #1996

Merged

Conversation

romainmenke
Copy link
Contributor

fixes: #1995

@@ -33,6 +33,9 @@ class Input {
this.hasBOM = false
}

this.document = this.css
if (opts.document) this.document = opts.document.toString()
Copy link
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
lib/input.d.ts Outdated
* Input source with support for non-CSS documents.
*
* ```js
* const input = postcss.parse('a{}', { from: file }).input
Copy link
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

lib/postcss.d.ts Outdated Show resolved Hide resolved
@ai
Copy link
Member

ai commented Dec 25, 2024

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 and others added 2 commits December 26, 2024 12:26
Co-authored-by: Andrey Sitnik <andrey@sitnik.ru>
@romainmenke
Copy link
Contributor Author

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

@ai ai merged commit 80e2401 into postcss:main Jan 13, 2025
9 checks passed
@romainmenke romainmenke deleted the input.document--exuberant-piranha-0b3a5fbff6 branch January 13, 2025 18:50
@ai
Copy link
Member

ai commented Jan 13, 2025

Thanks! The new property was released in 8.5.0.

@romainmenke
Copy link
Contributor Author

Thank you @ai for the reviews and release 🙇

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