Add the comment about to use mem::transmute() for values contained in DOMRefCell.

This commit is contained in:
Tetsuharu OHZEKI 2014-10-16 10:48:23 +09:00
parent d54fb041ba
commit ab90c718eb

View file

@ -1084,11 +1084,13 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
impl<'a> style::TElement<'a> for JSRef<'a, Element> { impl<'a> style::TElement<'a> for JSRef<'a, Element> {
fn get_attr(self, namespace: &Namespace, attr: &Atom) -> Option<&'a str> { fn get_attr(self, namespace: &Namespace, attr: &Atom) -> Option<&'a str> {
self.get_attribute(namespace.clone(), attr).root().map(|attr| { self.get_attribute(namespace.clone(), attr).root().map(|attr| {
// This transmute is used to cheat the lifetime restriction.
unsafe { mem::transmute(attr.value().as_slice()) } unsafe { mem::transmute(attr.value().as_slice()) }
}) })
} }
fn get_attrs(self, attr: &Atom) -> Vec<&'a str> { fn get_attrs(self, attr: &Atom) -> Vec<&'a str> {
self.get_attributes(attr).iter().map(|attr| attr.root()).map(|attr| { self.get_attributes(attr).iter().map(|attr| attr.root()).map(|attr| {
// This transmute is used to cheat the lifetime restriction.
unsafe { mem::transmute(attr.value().as_slice()) } unsafe { mem::transmute(attr.value().as_slice()) }
}).collect() }).collect()
} }