Skip to content

Commit 4a08d23

Browse files
author
Arjan Mels
committed
Corrected margin collapse
1 parent 05f9966 commit 4a08d23

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/html_parser.dart

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -756,20 +756,13 @@ class HtmlParser extends StatelessWidget {
756756
tree.children[i - 1].style.margin?.bottom?.value ?? 0;
757757
final thisTop = tree.children[i].style.margin?.top?.value ?? 0;
758758
final newInternalMargin = max(previousSiblingBottom, thisTop);
759-
760-
if (tree.children[i - 1].style.margin == null) {
761-
tree.children[i - 1].style.margin =
762-
Margins.only(bottom: newInternalMargin);
763-
} else {
764-
tree.children[i - 1].style.margin = tree.children[i - 1].style.margin!
765-
.copyWithEdge(bottom: newInternalMargin);
766-
}
759+
final newTop = newInternalMargin - previousSiblingBottom;
767760

768761
if (tree.children[i].style.margin == null) {
769-
tree.children[i].style.margin = Margins.only(top: newInternalMargin);
762+
tree.children[i].style.margin = Margins.only(top: newTop);
770763
} else {
771764
tree.children[i].style.margin = tree.children[i].style.margin!
772-
.copyWithEdge(top: newInternalMargin);
765+
.copyWithEdge(top: newTop);
773766
}
774767
}
775768
}

0 commit comments

Comments
 (0)