You should store imageData inside a JS pointer, like so (assuming ImageData is also a #[dom_struct])
#[dom_struct] pub struct ImageRequest { reflector_: Reflector, state : ImageState, currentUrl : URL, imageData : JS<ImageData>, } See XMLHttpRequest::Upload <https://github.com/servo/servo/blob/2dab0e15845f3ae625ca4b89facd62c2f2adb8b3/components/script/dom/xmlhttprequest.rs#L464> for an example of this pattern being used in a getter. You can do the same with the `url` attribute; however in this case it might be preferable to store a parsed URL (url::Url <http://doc.servo.org/url/struct.Url.html>), instead of a Javascript URL object (dom::url::URL <http://doc.servo.org/script/dom/url/struct.URL.html>). You can use URL::new_inherited() to create a JS URL from a regular one. The reason it expects Root is because these are Javascript objects, and the DOM structs are just the "Rust side of things"). Root/JS wraps around the struct and includes things like how it interacts with the JS garbage collector. The only time you should be returning a non-Root type is if it's a primitive, string, or a webidl-defined enum (e.g. WebSocket::BinaryType <https://github.com/servo/servo/blob/2dab0e15845f3ae625ca4b89facd62c2f2adb8b3/components/script/dom/websocket.rs#L374>, defined here <https://github.com/servo/servo/blob/2dab0e15845f3ae625ca4b89facd62c2f2adb8b3/components/script/dom/webidls/WebSocket.webidl#L7> ). Looking at your PR, you'll also need to add the webidl file (as well as a dom module) for ImageData <https://html.spec.whatwg.org/multipage/scripting.html#imagedata>. Do you have a link to the spec for ImageRequest? I couldn't find it after some quick searching. Let me know if you need more help! Thanks, -Manish Goregaokar _______________________________________________ dev-servo mailing list dev-servo@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-servo