aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltablecolelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmltablecolelement.rs')
-rw-r--r--components/script/dom/htmltablecolelement.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/components/script/dom/htmltablecolelement.rs b/components/script/dom/htmltablecolelement.rs
index c7ad4afd944..9e8eecf1147 100644
--- a/components/script/dom/htmltablecolelement.rs
+++ b/components/script/dom/htmltablecolelement.rs
@@ -20,8 +20,6 @@ use crate::dom::node::Node;
use crate::dom::virtualmethods::VirtualMethods;
use crate::script_runtime::CanGc;
-const DEFAULT_SPAN: u32 = 1;
-
#[dom_struct]
pub(crate) struct HTMLTableColElement {
htmlelement: HTMLElement,
@@ -62,9 +60,11 @@ impl HTMLTableColElement {
impl HTMLTableColElementMethods<crate::DomTypeHolder> for HTMLTableColElement {
// <https://html.spec.whatwg.org/multipage/#attr-col-span>
- make_uint_getter!(Span, "span", DEFAULT_SPAN);
+ make_uint_getter!(Span, "span", 1);
// <https://html.spec.whatwg.org/multipage/#attr-col-span>
- make_uint_setter!(SetSpan, "span", DEFAULT_SPAN);
+ // > The span IDL attribute must reflect the content attribute of the same name. It is clamped
+ // > to the range [1, 1000], and its default value is 1.
+ make_clamped_uint_setter!(SetSpan, "span", 1, 1000, 1);
}
pub(crate) trait HTMLTableColElementLayoutHelpers<'dom> {
@@ -96,11 +96,12 @@ impl VirtualMethods for HTMLTableColElement {
fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue {
match *local_name {
local_name!("span") => {
- let mut attr = AttrValue::from_u32(value.into(), DEFAULT_SPAN);
+ let mut attr = AttrValue::from_u32(value.into(), 1);
if let AttrValue::UInt(_, ref mut val) = attr {
- if *val == 0 {
- *val = 1;
- }
+ // From <https://html.spec.whatwg.org/multipage/#attr-col-span>:
+ // > The span IDL attribute must reflect the content attribute of the same name.
+ // > It is clamped to the range [1, 1000], and its default value is 1.
+ *val = (*val).clamp(1, 1000);
}
attr
},