mirror of
https://github.com/servo/servo.git
synced 2025-06-18 05:14:28 +00:00
Make datetime just reflect
This commit is contained in:
parent
d918c14247
commit
fa912b01ea
2 changed files with 4 additions and 21 deletions
|
@ -2,14 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::ElementBinding::ElementBinding::ElementMethods;
|
|
||||||
use dom::bindings::codegen::Bindings::HTMLTimeElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLTimeElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLTimeElementBinding::HTMLTimeElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLTimeElementBinding::HTMLTimeElementMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::Element;
|
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
use html5ever_atoms::LocalName;
|
use html5ever_atoms::LocalName;
|
||||||
|
@ -38,18 +35,7 @@ impl HTMLTimeElement {
|
||||||
|
|
||||||
impl HTMLTimeElementMethods for HTMLTimeElement {
|
impl HTMLTimeElementMethods for HTMLTimeElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-time-datetime
|
// https://html.spec.whatwg.org/multipage/#dom-time-datetime
|
||||||
//make_getter!(DateTime, "datetime");
|
make_getter!(DateTime, "datetime");
|
||||||
fn DateTime(&self) -> DOMString {
|
|
||||||
let element = self.upcast::<Element>();
|
|
||||||
if element.has_attribute(&local_name!("datetime")) {
|
|
||||||
return element.get_string_attribute(&local_name!("datetime"))
|
|
||||||
} else {
|
|
||||||
match element.GetInnerHTML() {
|
|
||||||
Ok(x) => x,
|
|
||||||
_ => DOMString::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-time-datetime
|
// https://html.spec.whatwg.org/multipage/#dom-time-datetime
|
||||||
make_setter!(SetDateTime, "datetime");
|
make_setter!(SetDateTime, "datetime");
|
||||||
|
|
|
@ -59,11 +59,8 @@ test(function () {
|
||||||
assert_equals( makeTime('go fish').dateTime, 'go fish' );
|
assert_equals( makeTime('go fish').dateTime, 'go fish' );
|
||||||
}, 'the datetime attribute should be reflected by the .dateTime property even if it is invalid');
|
}, 'the datetime attribute should be reflected by the .dateTime property even if it is invalid');
|
||||||
test(function() {
|
test(function() {
|
||||||
assert_equals( makeTime(false,'2000-02-01T03:04:05Z', '2000-02-01').dateTime, '2000-02-01' );
|
assert_equals( makeTime(false,'2000-02-01T03:04:05Z').dateTime, '' );
|
||||||
}, 'the datetime content attribute should not reflect the textContent when datetime attribute is present.');
|
}, 'the datetime attribute should not reflect the textContent');
|
||||||
test(function () {
|
|
||||||
assert_equals( makeTime(false,'2000-02-01T03:04:05Z').dateTime, '2000-02-01T03:04:05Z' );
|
|
||||||
}, 'the datetime content attribute should reflect the textContent when datetime attribute is absent.');
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue