Skip to content

fix: [#2035] Updates README.md for the server-renderer package#2037

Merged
capricorn86 merged 1 commit into
masterfrom
2035-fix-documentation-for-server-renderer
Jan 23, 2026
Merged

fix: [#2035] Updates README.md for the server-renderer package#2037
capricorn86 merged 1 commit into
masterfrom
2035-fix-documentation-for-server-renderer

Conversation

@capricorn86
Copy link
Copy Markdown
Owner

No description provided.

@capricorn86 capricorn86 linked an issue Jan 23, 2026 that may be closed by this pull request
@capricorn86 capricorn86 merged commit aa2dbb8 into master Jan 23, 2026
6 checks passed
@capricorn86 capricorn86 deleted the 2035-fix-documentation-for-server-renderer branch January 23, 2026 00:19
RAprogramm pushed a commit to RAprogramm/fork-happy-dom that referenced this pull request Feb 20, 2026
capricorn86 added a commit that referenced this pull request Jun 2, 2026
* fix: [#2035] Updates README.md for the server-renderer package (#2037)

* feat: [#241] Add canvas adapter pattern for pluggable rendering support

Adds ICanvasAdapter interface and static setCanvasAdapter() method to HTMLCanvasElement,
allowing users to plug in real canvas implementations like node-canvas.

Changes:
- Add ICanvasAdapter interface with getContext(), toDataURL(), toBlob() methods
- Add HTMLCanvasElement.setCanvasAdapter() and getCanvasAdapter() static methods
- Delegate canvas operations to adapter when set
- Add NodeCanvasAdapter implementation using node-canvas library
- Add comprehensive tests (44 new tests)

This enables real canvas rendering in Happy-DOM when node-canvas is installed:

```typescript
import { HTMLCanvasElement } from 'happy-dom';
import { NodeCanvasAdapter } from 'happy-dom/lib/nodes/html-canvas-element/adapters/NodeCanvasAdapter.js';

HTMLCanvasElement.setCanvasAdapter(new NodeCanvasAdapter());
// Now canvas.getContext('2d') returns real CanvasRenderingContext2D
```

Closes #241

* fix: [#241] Fix linting errors and code style

- Fix member ordering in HTMLCanvasElement class
- Add curly braces to all if statements
- Add public access modifiers to methods
- Add JSDoc comments for all parameters
- Use angle bracket type assertions in tests
- Fix code formatting per project standards

* fix: [#1850] Selection API focusNode and focusOffset returning incorrect values (#1953)

- Fixed focusNode getter to return the correct focus boundary point
based on selection direction
- Fixed focusOffset getter to return the correct focus offset based on
selection direction

* fix: [#1952] Accept Document nodes as valid boundary points in Selection API (#1954)

* feat: [#2049] Adds support for caching the compiled code of EcmaScript modules (#2050)

* feat: [#2049] Adds support for caching the compiled code of EcmaScript modules

* feat: [#2049] Adds support for caching the compiled code of EcmaScript modules

* feat: [#2049] Adds support for caching the compiled code of EcmaScript modules

* feat: [#2055] Changes internal types to follow a consistent pattern (#2056)

* fix: [#1955] Fixes stepUp and stepDown on HTMLInputElement according to spec (#1960)

* fix: [#1955] Conforming stepUp and stepDown on HTMLInputElement to spec for number inputs

* chore: [#1960] Fixes implementation to follow the spec and the project coding style

* chore: [#1960] Fixes implementation to follow the spec and the project coding style

---------

* fix: [#1947] Use entities package for HTML/XML encoding/decoding (#2016)

- Replace decodeHTMLAttributeValue with entities.decodeHTMLAttribute
- Replace decodeHTMLEntities with entities.decodeHTML
- Replace decodeXMLAttributeValue with entities.decodeXML
- Replace decodeXMLEntities with entities.decodeXML
- Replace encodeTextContent with entities.escapeText
- Add entities@6 as dependency
- Remove unused regex patterns and lookup tables
- Add test for numeric character reference decoding in attributes

This fixes issue #1947 where numeric character references like "
and " were not being decoded in HTML attribute values.

* chore: [#1947] Adds unit tests for decode ' / numeric character references in attr values (#1948)

- attribute values can contain named and numeric character references
  per https://html.spec.whatwg.org/multipage/syntax.html#syntax-attribute-value
- add decoding for all numeric character references
- add decoding for ', this could probably appear in single-quoted
  attribute values
- ignore other named character references, the list is huge

* fix: Node.replaceWith does not throw w/o parent (#1969)

* fix: Node.replaceWith does not throw w/o parent

```js
let div = document.createElement("div");
let span = document.createElement("span");

div.parentNode; // null
span.parentNode; // null

div.replaceWith(span); // ok
```

* chore: remove unused DOMException import

* chore: [#0] Adds unit test

---------

* fix: [#1959] Implement Text.wholeText property (#2027)

* fix: [#1959] Implement Text.wholeText property

* fix: [#1959] Implement Text.wholeText property

---------

* fix: [#2052] Correct caption element content model to allow flow content (#2058)

Fixes #2052

## Problem

The caption element was incorrectly configured with contentModel: textOrComments,
which only allowed text nodes and comments. Per the HTML spec, caption elements
should contain flow content (inline and block elements), except table elements.

This caused elements like <b>, <em>, <span>, etc. to be incorrectly moved
outside the caption during parsing.

## Changes

### packages/happy-dom/src/config/HTMLElementConfig.ts

Updated caption element configuration to match the HTML spec and follow the
same pattern as td/th elements:

- Changed contentModel from textOrComments to noForbiddenFirstLevelDescendants
- Added forbiddenDescendants: table structure elements (table, tbody, thead,
  tfoot, tr, td, th, col, colgroup)
- Added permittedParents: ['table'] to ensure caption only appears in tables

### packages/happy-dom/test/html-parser/HTMLParser.malformedHTML.test.ts

Added comprehensive test coverage for caption element content model:
- Inline elements preservation (b, strong, em, span, a)
- Nested inline elements
- Block-level elements (p, div)
- Table element prohibition
- Content serialization
- permittedParents validation (wrong parent, standalone, correct parent)

## Implementation Details

This fix follows the same pattern as PR #2007 for paragraph elements, using
the existing noForbiddenFirstLevelDescendants content model. While this
doesn't recursively check deeply nested table elements, it matches the
existing codebase patterns and handles the vast majority of real-world cases.

* feat: [#2060] Adds support for register on import in global-registrator (#2061)

* fix: [#2057] Support Unicode characters in selectors per CSS spec (#2062)

* fix: [#2057] Support Unicode characters in selectors per CSS spec

The CSS specification allows identifiers (class names, IDs, element names)
to contain ISO 10646 characters U+00A0 and higher. The regex patterns in
SelectorParser.ts were only allowing ASCII characters plus a hardcoded
workaround for guillemets.

This change updates both SELECTOR_REGEXP and SIMPLE_SELECTOR_REGEXP to
accept characters in the range \u00A0-\uFFFF, which covers Greek letters,
CJK characters, Cyrillic, Arabic, Hebrew, and other Unicode scripts.

* chore: [#2057] Adds unit tests

* chore: [#2057] Adds unit tests

---------

* fix: [#2042] Support CSS gradients with rgba() colors (#2059)

* fix: [#2042] Support CSS gradients with rgba() colors

This fix resolves an issue where CSS background properties containing
linear gradients with rgba() color values would return empty strings.

Root Cause:
- GRADIENT_REGEXP pattern used [^)]+ which stopped at the first closing
  parenthesis, failing to match gradients with nested rgba() functions
- String splitting logic didn't respect nested parentheses, incorrectly
  splitting rgba(0, 0, 0, 0) into multiple invalid parts

Solution:
- Updated GRADIENT_REGEXP to handle one level of nested parentheses
- Improved getGradient() to split commas while respecting parentheses depth
- Added splitByComma() and splitBySpace() helper functions to properly
  handle nested parentheses when parsing CSS values
- Updated getBackground() and getBackgroundImage() to use new helpers

Tests:
- Added 15 comprehensive test cases covering rgba(), hsla(), rgb(), hsl()
- Tests include repeating gradients, conic gradients, multiple gradients
- Tests verify edge cases: many color stops, decimal values, whitespace
- All 7,184 tests pass

chore: [#2042] Format test file

* fix: [#2042] Improves performance on splitting

* fix: [#2042] Improves performance on splitting

* fix: [#2042] Improves performance on splitting

---------

* fix: [#2066] Update entities package version to resolve missing export for vue and vue-compat v3.5 (#2067)

* fix: [#1910] Fixes issue when parsing complex query selector with has expression (#2068)

* fix: [#1910] Fixes issue when parsing complex CSS has expression

* fix: [#1910] Fixes issue when parsing complex CSS has expression

* fix: [#1910] Fixes issue when parsing complex CSS has expression

* feat: [#241] Refactor canvas adapter to use browser settings

* feat: [#241] Fix `index.ts` missing import

* feat: [#241] Add tests and documentation for node-canvas-adapter

- Add 13 comprehensive tests for CanvasAdapter
- Add .gitignore and .npmignore files
- Enhance README.md with usage examples and API documentation
- Update package.json with scripts, keywords and complete metadata
- Update tsconfig.json with additional compiler options
- Add canvas documentation to happy-dom README

* feat: [#241] Update `package-json.lock`

* feat: [#241] Add canvas adapter pattern for pluggable rendering support

* feat: [#241] Canvas. Fix imports and callback sig

* feat: [#241] Skip canvas tests if canvas not exists

* feat: [#241] Add missing field to mocks

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

* chore: [#0] Continues on implementation

---------

Co-authored-by: David Ortner <david@ortner.se>
Co-authored-by: Sergey Kochetkov <skoch13@icloud.com>
Co-authored-by: Steve Matney <steve.matney@gmail.com>
Co-authored-by: Trevor Burnham <trevorburnham@gmail.com>
Co-authored-by: cgoetz-inovex <carlo.goetz@inovex.de>
Co-authored-by: Luke Edwards <lukeed@github.com>
Co-authored-by: TAKAGI AKIHIRO <156570014+aki05162525@users.noreply.github.com>
Co-authored-by: Atsushi Kawamura (atzz/a2c) <atsushi1230.sdi@gmail.com>
Co-authored-by: Kai Gritun <kaigritun@gmail.com>
Co-authored-by: Anthony Collins <acollins1991@users.noreply.github.com>
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.

Fix documentation for server-renderer

1 participant