Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix: disguised-ad-flag re-hid the article a user just revealed#160

Merged
twschiller merged 1 commit into
mainfrom
fix/disguised-ad-flag-reveal-loop
Jun 5, 2026
Merged

Fix: disguised-ad-flag re-hid the article a user just revealed#160
twschiller merged 1 commit into
mainfrom
fix/disguised-ad-flag-reveal-loop

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

  • Surfaced on the demo's "Recommended for you" section: clicking the placeholder restored the section, then it immediately re-hid itself.
  • Root cause is in disguised-ad-flag's isCandidateSkipped: the reveal stamp (data-abs-revealed) lands on the article ancestor the rule replaced, but the skip check only looked at the label element (element.hasAttribute(REVEALED_ATTR)). On the next mutation burst the watcher re-found the same Sponsored label, findArticleAncestor walked up to the same revealed article, and hideCandidate re-wrapped it — an unrevealable loop.
  • Switch the check to a rule-scoped closest([data-abs-revealed="disguised-ad-flag"]) walk so reveal stamps on any ancestor (including the article itself) are honored, while reveal stamps from other rules don't accidentally suppress this rule.

Not a regression from the #150 perf tiers — the same call sequence reproduces against pre-Tier-1 code. The trailing-only throttle (#151) just makes the re-hide land in a single ~250ms window, so it now reads as instantaneous instead of janky.

Test plan

  • bun run test (1258 passed, 65 suites)
  • bunx tsc --noEmit clean
  • bunx eslint clean on touched files
  • New disguised-ad-flag regression tests:
    • "does not re-hide an article the user revealed via click" — the original bug.
    • "re-hides a freshly-inserted advertorial card after a reveal elsewhere" — guards against the fix being too broad (sibling cards must still be hidden).
  • Manual check on https://shield-dark-pattern-demo.vercel.app/ — click reveal on "Recommended for you", confirm it stays revealed.

🤖 Generated with Claude Code

The reveal stamp (`data-abs-revealed`) lands on the article ancestor, not
the disclosure label. `isCandidateSkipped` only checked
`element.hasAttribute(REVEALED_ATTR)` on the label, so on the next mutation
burst the watcher re-found the same Sponsored label, walked up to the same
revealed article, and re-wrapped it into an unrevealable loop. Switch the
check to a rule-scoped `closest(...)` walk that honors the ancestor stamp.

Surfaced on the demo's "Recommended for you" section, which contains a
sponsored ProductCard inside an article-shaped grid wrapper.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 5, 2026 11:56am

Request Review

@twschiller twschiller merged commit 70e37a9 into main Jun 5, 2026
7 checks passed
@twschiller twschiller deleted the fix/disguised-ad-flag-reveal-loop branch June 5, 2026 12:04
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.

1 participant