mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-21 20:24:42 +00:00
fix OL.type default and TableCell span clamping per spec
OL.type returns "1" (not "") when attribute absent. TableCell.colSpan clamps to 1-1000, rowSpan to 0-65534.
This commit is contained in:
@@ -46,6 +46,6 @@
|
||||
testing.expectEqual('1', ol1.type);
|
||||
|
||||
const ol2 = document.getElementById('ol2');
|
||||
testing.expectEqual('', ol2.type);
|
||||
testing.expectEqual('1', ol2.type);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -18,6 +18,14 @@
|
||||
|
||||
const td2 = document.getElementById('td2');
|
||||
testing.expectEqual(1, td2.colSpan);
|
||||
|
||||
// colSpan 0 clamps to 1
|
||||
td2.colSpan = 0;
|
||||
testing.expectEqual(1, td2.colSpan);
|
||||
|
||||
// colSpan > 1000 clamps to 1000
|
||||
td2.colSpan = 9999;
|
||||
testing.expectEqual(1000, td2.colSpan);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -31,5 +39,13 @@
|
||||
|
||||
const td2 = document.getElementById('td2');
|
||||
testing.expectEqual(1, td2.rowSpan);
|
||||
|
||||
// rowSpan 0 is valid per spec (span remaining rows)
|
||||
td2.rowSpan = 0;
|
||||
testing.expectEqual(0, td2.rowSpan);
|
||||
|
||||
// rowSpan > 65534 clamps to 65534
|
||||
td2.rowSpan = 99999;
|
||||
testing.expectEqual(65534, td2.rowSpan);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -56,7 +56,7 @@ pub fn setReversed(self: *OL, value: bool, page: *Page) !void {
|
||||
}
|
||||
|
||||
pub fn getType(self: *OL) []const u8 {
|
||||
return self.asElement().getAttributeSafe(comptime .wrap("type")) orelse "";
|
||||
return self.asElement().getAttributeSafe(comptime .wrap("type")) orelse "1";
|
||||
}
|
||||
|
||||
pub fn setType(self: *OL, value: []const u8, page: *Page) !void {
|
||||
|
||||
@@ -21,7 +21,9 @@ pub fn asNode(self: *TableCell) *Node {
|
||||
|
||||
pub fn getColSpan(self: *TableCell) u32 {
|
||||
const attr = self.asElement().getAttributeSafe(comptime .wrap("colspan")) orelse return 1;
|
||||
return std.fmt.parseUnsigned(u32, attr, 10) catch 1;
|
||||
const v = std.fmt.parseUnsigned(u32, attr, 10) catch return 1;
|
||||
if (v == 0) return 1;
|
||||
return @min(v, 1000);
|
||||
}
|
||||
|
||||
pub fn setColSpan(self: *TableCell, value: u32, page: *Page) !void {
|
||||
@@ -31,7 +33,8 @@ pub fn setColSpan(self: *TableCell, value: u32, page: *Page) !void {
|
||||
|
||||
pub fn getRowSpan(self: *TableCell) u32 {
|
||||
const attr = self.asElement().getAttributeSafe(comptime .wrap("rowspan")) orelse return 1;
|
||||
return std.fmt.parseUnsigned(u32, attr, 10) catch 1;
|
||||
const v = std.fmt.parseUnsigned(u32, attr, 10) catch return 1;
|
||||
return @min(v, 65534);
|
||||
}
|
||||
|
||||
pub fn setRowSpan(self: *TableCell, value: u32, page: *Page) !void {
|
||||
|
||||
Reference in New Issue
Block a user