diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 88bb74f1978..798d7963e5d 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -50,6 +50,7 @@ use style::stylesheets::{Stylesheet, UrlExtraData}; use uuid::Uuid; use xml5ever::{local_name, serialize as xml_serialize}; +use super::types::CDATASection; use crate::conversions::Convert; use crate::document_loader::DocumentLoader; use crate::dom::attr::Attr; @@ -3458,16 +3459,18 @@ impl NodeMethods for Node { let mut children = self.children().enumerate().peekable(); while let Some((_, node)) = children.next() { if let Some(text) = node.downcast::() { + if text.is::() { + continue; + } let cdata = text.upcast::(); let mut length = cdata.Length(); if length == 0 { Node::remove(&node, self, SuppressObserver::Unsuppressed, can_gc); continue; } - while children - .peek() - .is_some_and(|(_, sibling)| sibling.is::()) - { + while children.peek().is_some_and(|(_, sibling)| { + sibling.is::() && !sibling.is::() + }) { let (index, sibling) = children.next().unwrap(); sibling .ranges() diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 481c2f286c6..59b4ef93035 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -1260,7 +1260,7 @@ impl WeakRangeVec { .extend(ranges.drain(..)); } - /// Used for steps 7.1-2. when normalizing a node. + /// Used for steps 6.1-2. when normalizing a node. /// pub(crate) fn drain_to_preceding_text_sibling(&self, node: &Node, sibling: &Node, length: u32) { if self.is_empty() { @@ -1287,7 +1287,7 @@ impl WeakRangeVec { sibling.ranges().cell.borrow_mut().extend(ranges.drain(..)); } - /// Used for steps 7.3-4. when normalizing a node. + /// Used for steps 6.3-4. when normalizing a node. /// pub(crate) fn move_to_text_child_at( &self, diff --git a/tests/wpt/meta/dom/nodes/Node-normalize.html.ini b/tests/wpt/meta/dom/nodes/Node-normalize.html.ini deleted file mode 100644 index 8c1f157ee0c..00000000000 --- a/tests/wpt/meta/dom/nodes/Node-normalize.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[Node-normalize.html] - [Non-text nodes with empty textContent values.] - expected: FAIL