aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index e9d36a01426..ca785773b48 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -3110,11 +3110,15 @@ impl NodeMethods<crate::DomTypeHolder> for Node {
/// <https://dom.spec.whatwg.org/#dom-node-childnodes>
fn ChildNodes(&self, can_gc: CanGc) -> DomRoot<NodeList> {
- self.ensure_rare_data().child_list.or_init(|| {
- let doc = self.owner_doc();
- let window = doc.window();
- NodeList::new_child_list(window, self, can_gc)
- })
+ if let Some(list) = self.ensure_rare_data().child_list.get() {
+ return list;
+ }
+
+ let doc = self.owner_doc();
+ let window = doc.window();
+ let list = NodeList::new_child_list(window, self, can_gc);
+ self.ensure_rare_data().child_list.set(Some(&list));
+ list
}
/// <https://dom.spec.whatwg.org/#dom-node-firstchild>