Skip to content

Separate test runner and other imrovements #57

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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

danny0838
Copy link
Contributor

As explained in the commit messages.

@danny0838 danny0838 changed the title Separate test runner and minor changes Separate test runner and other imrovements Apr 6, 2024
@danny0838 danny0838 force-pushed the main branch 3 times, most recently from b84d3ff to 4ebbcc5 Compare April 7, 2024 06:48
@danny0838
Copy link
Contributor Author

Is there still some problem with these commits? It should be OK to merge this before #54 and #56, which I can rebase them afterwards.

@tabatkins
Copy link
Owner

Nope, it's purely been a matter of me not having the time to review them.

danny0838 added 24 commits July 20, 2024 21:07
- Separate the test runner script to a new test.js file so that the developers of other projects can import and run the test cases on their own.
- This prevents the parseerror message show "0x-1".
- There is no \x00, which has been replaced during preprocessing, in the input codepoints.
- Wrap internal variables in a closure to prevent repeated instantiation when called.
- Define every internal function using a direct function expression rather than an anonymous function.
@danny0838
Copy link
Contributor Author

Rebased on top of #59.

@danny0838
Copy link
Contributor Author

@tabatkins I'm wondering if there's still any plan to continue development on this parser. Since it has been halted for over a year.

As a developer, I’m in need of a spec-compliant CSS parser that can safely handle CSS rewriting, especially in edge cases. Ideally, I’d like to use an existing, well-maintained parser rather than building one from scratch.

I've tried several popular parsing libraries like postcss, but unfortunately they don’t meet my requirements. Most of them implement their own tokenization and parsing logic, which can diverge from the CSS spec. Additionally, they often enforce strict error handling, throwing exceptions on invalid CSS. In contrast, I need a parser that can recover gracefully and perform minimal error repair during parsing.

That said, I’ve noticed some limitations in this project that may make it less suitable for my use case:

  1. Reproducible parsing: I'm working on a CSS rewriter that needs to preserve as much of the original source text as possible — including whitespace, line breaks, and comments — in order to safely rewrite only specific parts, like URLs.
    However, this parser corrently removes such information according to the spec. Additionally, characters such as linefeeds, control characters, and bad surrogate pairs are also eliminated during the preprocess step.
    I'd have to rewrite the tokenizer/parser to add option(s) to allow them to record the bound source code of each tokens, and add comment tokens to preserve such information when desired. Some of my recent PRs are for this.

  2. ES6 module support: These days, ES6 modules are widely preferred for JavaScript projects. They’re easier to analyze, test, and bundle into other formats like IIFE, UMD, minified, or polyfilled builds. It's also fairly easy to use directly in a modern browser (Chromium >= 61, Firefox >= 60).

I'd really appreciate your thoughts on both points. The second one seems fairly easy to implement if you're in agreement. The first may require more discussion and design considerations. If this project isn’t intended to support such extended use cases, I may need to fork it or build something custom. That said, I hope the spec can evolve in a way that accommodates these types of real-world usage scenarios (e.g., by allowing comment tokens or preserving source information). Otherwise, developers may be forced to rely on non-spec-compliant parsers, which undermines the goal of having a shared, universal standard.

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.

2 participants