Skip to content

Commit 2434365

Browse files
authored
feat: support border-spacing (#294)
1 parent 1e7d0f9 commit 2434365

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

src/lib.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,73 @@ mod tests {
257257
};
258258
);
259259

260+
#[test]
261+
pub fn test_border_spacing() {
262+
minify_test(
263+
r#"
264+
.foo {
265+
border-spacing: 0px;
266+
}
267+
"#,
268+
indoc! {".foo{border-spacing:0}"
269+
},
270+
);
271+
minify_test(
272+
r#"
273+
.foo {
274+
border-spacing: 0px 0px;
275+
}
276+
"#,
277+
indoc! {".foo{border-spacing:0}"
278+
},
279+
);
280+
281+
minify_test(
282+
r#"
283+
.foo {
284+
border-spacing: 12px 0px;
285+
}
286+
"#,
287+
indoc! {".foo{border-spacing:12px 0}"
288+
},
289+
);
290+
291+
minify_test(
292+
r#"
293+
.foo {
294+
border-spacing: calc(3px * 2) calc(5px * 0);
295+
}
296+
"#,
297+
indoc! {".foo{border-spacing:6px 0}"
298+
},
299+
);
300+
301+
minify_test(
302+
r#"
303+
.foo {
304+
border-spacing: calc(3px * 2) max(0px, 8px);
305+
}
306+
"#,
307+
indoc! {".foo{border-spacing:6px 8px}"
308+
},
309+
);
310+
311+
// TODO: The `<length>` in border-spacing cannot have a negative value,
312+
// we may need to implement NonNegativeLength like Servo does.
313+
// Servo Code: https://github.com/servo/servo/blob/08bc2d53579c9ab85415d4363888881b91df073b/components/style/values/specified/length.rs#L875
314+
// CSSWG issue: https://lists.w3.org/Archives/Public/www-style/2008Sep/0161.html
315+
// `border-spacing = <length> <length>?`
316+
minify_test(
317+
r#"
318+
.foo {
319+
border-spacing: -20px;
320+
}
321+
"#,
322+
indoc! {".foo{border-spacing:-20px}"
323+
},
324+
);
325+
}
326+
260327
#[test]
261328
pub fn test_border() {
262329
test(

src/properties/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,8 @@ define_properties! {
805805
"inset-inline": InsetInline(InsetInline) shorthand: true,
806806
"inset": Inset(Inset) shorthand: true,
807807

808+
"border-spacing": BorderSpacing(Size2D<Length>),
809+
808810
"border-top-color": BorderTopColor(CssColor) [logical_group: BorderColor, category: Physical],
809811
"border-bottom-color": BorderBottomColor(CssColor) [logical_group: BorderColor, category: Physical],
810812
"border-left-color": BorderLeftColor(CssColor) [logical_group: BorderColor, category: Physical],

0 commit comments

Comments
 (0)