WebReflection / WebReflection/linkedom

Replace CSSOM so new CSS features are supported

Open
#318 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
2.1k
Forks
104
PR merge metrics
No merged PRs in 30d

Description

Hi,

I noticed that currently linkedom fails to parse styles with nested CSS rules. Here's a sample code:

import {parseHTML} from "linkedom";

const doc = parseHTML(`
<style>
	.parent { .child { color: red; }}
</style>
`).document;
console.log(doc.children[0].sheet);

Looking into it, it seems like this is an issue with CSSOM, which makes sense considering that project stopped receiving updates 5 years ago and is marked as unmaintained. Although I didn't check, I assume other kinds of 'modern' CSS rules will also raise an exception when parsed.

I would like to know if there is interest in replacing it with an up-to-date CSS parser implementation.

Looking online, I found a benchmark that shows that a few other CSS parsers more or less match the performance of CSSOM, which I know is an important factor for this project.

If this is desired I can take a look into changing the backing implementation, probably trying the projects in the order they appear in that benchmark (I don't know which of those provides the functionalities linkedom requires).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the parseHTML example in the issue and inspect how linkedom integrates CSSOM; no source file or test is named. Compare current CSSOM behavior with candidate parsers from the linked benchmark. Done means nested CSS and other modern CSS rules parse without exceptions while the needed CSS functionality and performance remain acceptable.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
frontend, web-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.