Skip to content

Commit acc288c

Browse files
authored
Merge pull request Sub6Resources#653 from tneotia/bugfix/before-and-afters
Fix Stack Overflow error when using before and afters
2 parents 89a89ba + ca7d26a commit acc288c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/html_parser.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,14 +577,15 @@ class HtmlParser extends StatelessWidget {
577577
static StyledElement _processBeforesAndAfters(StyledElement tree) {
578578
if (tree.style.before != null) {
579579
tree.children.insert(
580-
0, TextContentElement(text: tree.style.before, style: tree.style));
580+
0, TextContentElement(text: tree.style.before, style: tree.style.copyWith(beforeAfterNull: true, display: Display.INLINE)));
581581
}
582582
if (tree.style.after != null) {
583583
tree.children
584-
.add(TextContentElement(text: tree.style.after, style: tree.style));
585-
} else {
586-
tree.children.forEach(_processBeforesAndAfters);
584+
.add(TextContentElement(text: tree.style.after, style: tree.style.copyWith(beforeAfterNull: true, display: Display.INLINE)));
587585
}
586+
587+
tree.children.forEach(_processBeforesAndAfters);
588+
588589
return tree;
589590
}
590591

lib/style.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ class Style {
348348
Border? border,
349349
Alignment? alignment,
350350
String? markerContent,
351+
bool? beforeAfterNull,
351352
}) {
352353
return Style(
353354
backgroundColor: backgroundColor ?? this.backgroundColor,
@@ -377,8 +378,8 @@ class Style {
377378
whiteSpace: whiteSpace ?? this.whiteSpace,
378379
width: width ?? this.width,
379380
wordSpacing: wordSpacing ?? this.wordSpacing,
380-
before: before ?? this.before,
381-
after: after ?? this.after,
381+
before: beforeAfterNull == true ? null : before ?? this.before,
382+
after: beforeAfterNull == true ? null : after ?? this.after,
382383
border: border ?? this.border,
383384
alignment: alignment ?? this.alignment,
384385
markerContent: markerContent ?? this.markerContent,

0 commit comments

Comments
 (0)