script: delay Mutation initialization (#35291)

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-02-05 14:28:10 +08:00 committed by GitHub
parent 503bb10c5b
commit 789736590b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 23 deletions

View file

@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! DOM bindings for `CharacterData`.
use std::cell::LazyCell;
use dom_struct::dom_struct;
@ -100,9 +101,9 @@ impl CharacterData {
// Queue a MutationObserver record before changing the content.
fn queue_mutation_record(&self) {
let mutation = Mutation::CharacterData {
let mutation = LazyCell::new(|| Mutation::CharacterData {
old_value: self.data.borrow().clone(),
};
});
MutationObserver::queue_a_mutation_record(self.upcast::<Node>(), mutation);
}
}