[PR #1516] [MERGED] fix(browser): keep the first DOM attribute when the name is repeated #2936

Closed
opened 2026-10-17 21:12:01 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1516
Author: @taljeri
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @morluto

Base: main ← Head: fix/browser-dom-first-attribute


📝 Commits (4)

  • cc145a9 fix(browser): keep the first DOM attribute when the name is repeated
  • 34b7795 fix(browser): preserve case-sensitive DOM attribute names
  • 7eea03b Merge remote-tracking branch 'origin/main' into HEAD
  • a73ce96 test(browser): align repeated attribute coverage with deduplication

📊 Changes

2 files changed (+69 additions, -5 deletions)

View changed files

📝 src/browser/CdpCaptureDocuments.baseUrl.test.ts (+55 -1)
📝 src/browser/CdpCaptureDocuments.ts (+14 -4)

📄 Description

Summary

Fixes #1496

Page capture lists DOM attributes and computes URLs/hints from them. When an element carried duplicate attribute declarations (e.g. repeated href, action, or src), domMetadata folded them into a Map with pairs.set(), causing later duplicate values to overwrite earlier ones.

In HTML, the first declaration is kept when an attribute name is repeated. This aligns domMetadata and attribute_names to preserve the first occurrence case-insensitively, ensuring that attribute_names and dom_urls describe the same attributes according to HTML rules.

Changes

  • In src/browser/CdpCaptureDocuments.ts, keep the first attribute occurrence in domMetadata using if (!pairs.has(name)) pairs.set(...).
  • Deduplicate attribute_names on each node by case-insensitive first appearance.
  • Add regression test in src/browser/CdpCaptureDocuments.baseUrl.test.ts.

Verification

  • npm run test:focused -- src/browser/CdpCaptureDocuments.baseUrl.test.ts src/browser/CdpCaptureDocuments.test.ts (all passed)
  • npm run check:fast (typecheck & lint clean)
  • npm run docs:check (clean metadata contracts)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1516 **Author:** [@taljeri](https://github.com/taljeri) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/browser-dom-first-attribute` --- ### 📝 Commits (4) - [`cc145a9`](https://github.com/morluto/rea/commit/cc145a95db8009728e7d22d7407a29a587c2366a) fix(browser): keep the first DOM attribute when the name is repeated - [`34b7795`](https://github.com/morluto/rea/commit/34b77957096676bc811243db7e9f4484755ff1a5) fix(browser): preserve case-sensitive DOM attribute names - [`7eea03b`](https://github.com/morluto/rea/commit/7eea03bbfa6e312d0f8a18c045e4baeecefefa88) Merge remote-tracking branch 'origin/main' into HEAD - [`a73ce96`](https://github.com/morluto/rea/commit/a73ce961915b1f580050dcb8c564504722ce1115) test(browser): align repeated attribute coverage with deduplication ### 📊 Changes **2 files changed** (+69 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/CdpCaptureDocuments.baseUrl.test.ts` (+55 -1) 📝 `src/browser/CdpCaptureDocuments.ts` (+14 -4) </details> ### 📄 Description ## Summary Fixes #1496 Page capture lists DOM attributes and computes URLs/hints from them. When an element carried duplicate attribute declarations (e.g. repeated `href`, `action`, or `src`), `domMetadata` folded them into a Map with `pairs.set()`, causing later duplicate values to overwrite earlier ones. In HTML, the first declaration is kept when an attribute name is repeated. This aligns `domMetadata` and `attribute_names` to preserve the first occurrence case-insensitively, ensuring that `attribute_names` and `dom_urls` describe the same attributes according to HTML rules. ## Changes - In `src/browser/CdpCaptureDocuments.ts`, keep the first attribute occurrence in `domMetadata` using `if (!pairs.has(name)) pairs.set(...)`. - Deduplicate `attribute_names` on each node by case-insensitive first appearance. - Add regression test in `src/browser/CdpCaptureDocuments.baseUrl.test.ts`. ## Verification - `npm run test:focused -- src/browser/CdpCaptureDocuments.baseUrl.test.ts src/browser/CdpCaptureDocuments.test.ts` (all passed) - `npm run check:fast` (typecheck & lint clean) - `npm run docs:check` (clean metadata contracts) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:12:01 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2936
No description provided.