- From: Daniel Vogelheim <notifications@github.com>
- Date: Fri, 07 Feb 2025 08:02:14 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/pull/1268/c2643335248@github.com>
Hi all, sorry I'm a bit late with feedback. It turns out, what Chromium does here is buggy since we are running structure checks before the Trusted Type checks and then getting inconsistent results when a default policy modifies the attribute that is being checked. Thanks for pointing this out. My (new) preference would be to always run TT checks before any other steps; here and elsewhere. We mostly already do this. That would provide a strict sequencing of TT before any other DOM checks or DOM manipulations, and should IMHO solve this class of problems entirely. I'd be happier if we had a general rule here, and I'd rather do some more work on our end than risk us overlooking another issue like this. For testing, I'd propose to add WPT tests with competing error conditions and checking for the correct exception being thrown. (I.e., setting an attribute node that's already connected should throw the TT-style TypeException, not the InUseAttributeError DOMException). Something like the following seems to work when I try it locally: ```js <div onclick="1+1;" id="test"></div> <script> test(t => { var attribute = document.getElementById("test").getAttributeNode("id"); assert_throws_dom("InUseAttributeError", _ => { document.body.setAttributeNode(attribute); }, "Expect InUseAttributeError DOMException."); attribute = document.getElementById("test").getAttributeNode("onclick"); assert_throws_js(TypeError, _ => { document.body.setAttributeNode(attribute); }, "Expect a Trusted-Types style TypeError, not InUseAttributeError DOMException."); }, "Element.setAttribute competing exceptions"); </script> ``` -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/pull/1268#issuecomment-2643335248 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/pull/1268/c2643335248@github.com>
Received on Friday, 7 February 2025 16:02:18 UTC