mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Implement basic interface for MutationObserver and MutationRecord.
This commit is contained in:
parent
5421d833de
commit
107ac9ab56
8 changed files with 145 additions and 0 deletions
34
components/script/dom/mutationrecord.rs
Normal file
34
components/script/dom/mutationrecord.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::MutationRecordBinding::MutationRecordBinding::MutationRecordMethods;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::Reflector;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::node::Node;
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct MutationRecord {
|
||||
reflector_: Reflector,
|
||||
|
||||
//property for record type
|
||||
record_type: DOMString,
|
||||
|
||||
//property for target node
|
||||
target: JS<Node>,
|
||||
}
|
||||
|
||||
impl MutationRecordMethods for MutationRecord {
|
||||
// https://dom.spec.whatwg.org/#dom-mutationrecord-type
|
||||
fn Type(&self) -> DOMString {
|
||||
self.record_type.clone()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-mutationrecord-target
|
||||
fn Target(&self) -> Root<Node> {
|
||||
return Root::from_ref(&*self.target);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue