From abb017b8543efea54b732efa2846b25c949985c9 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Thu, 21 Dec 2023 09:14:00 +0100 Subject: [PATCH] script: Allow moving back to non-quirks mode (#30898) The code in script is written so that the document itself can move from quirks to non-quirks mode, but this is never communicated to layout -- meaning quirky layout keeps happening. This is an issue when rewriting the entire document with `document.write()` which is what some WPT tests do to test quirks mode behavior. --- components/script/dom/document.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 0150891d5fd..3ce1299a59b 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -823,12 +823,12 @@ impl Document { self.quirks_mode.get() } - pub fn set_quirks_mode(&self, mode: QuirksMode) { - self.quirks_mode.set(mode); + pub fn set_quirks_mode(&self, new_mode: QuirksMode) { + let old_mode = self.quirks_mode.replace(new_mode); - if mode == QuirksMode::Quirks { + if old_mode != new_mode { match self.window.layout_chan() { - Some(chan) => chan.send(Msg::SetQuirksMode(mode)).unwrap(), + Some(chan) => chan.send(Msg::SetQuirksMode(new_mode)).unwrap(), None => warn!("Layout channel unavailable"), } }