Skip to content

Commit a380ebc

Browse files
arjanmelsArjan Mels
and
Arjan Mels
authored
Mark Summary and Details as block items (#1276)
Co-authored-by: Arjan Mels <[email protected]>
1 parent d709199 commit a380ebc

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/src/builtins/styled_element_builtin.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ class StyledElementBuiltIn extends HtmlExtension {
399399
verticalAlign: VerticalAlign.sub,
400400
);
401401
break;
402+
case "summary":
403+
styledElement.style = Style(
404+
display: Display.block,
405+
);
406+
break;
402407
case "sup":
403408
styledElement.style = Style(
404409
fontSize: FontSize.smaller,

test/whitespace_test.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,32 @@ void main() {
6666
},
6767
);
6868

69+
//See https://github.com/Sub6Resources/flutter_html/issues/1275
70+
testWidgets(
71+
"test that extra newlines aren't added unnecessarily for details/summary tags",
72+
(tester) async {
73+
final tree = await generateStyledElementTreeFromHtml(
74+
tester,
75+
html: """
76+
<!DOCTYPE html>
77+
<html>
78+
<body>
79+
<details>
80+
<summary><h1>Header</h1></summary>
81+
<p>These are the details.</p>
82+
</details>
83+
</body>
84+
</html>
85+
""",
86+
);
87+
88+
expect(
89+
tree.getWhitespace(),
90+
equals(
91+
"<body><details><summary><h1>Header</h1></summary><p>These◦are◦the◦details.</p></details></body>"));
92+
},
93+
);
94+
6995
// See https://github.com/Sub6Resources/flutter_html/issues/1251
7096
testWidgets(
7197
'test that preserved whitespace is actually preserved',

0 commit comments

Comments
 (0)