Skip to content

Commit a5b4b7b

Browse files
committed
[FIX] ensure <br> is never identified as a block
Further reading on this issue: - w3c/csswg-drafts#610 - whatwg/html#2298 - https://stackoverflow.com/a/45143493/4633524 To test the native behavior of <br> in and out of a flexbox: https://jsfiddle.net/jko4fh9y/
1 parent dfd1789 commit a5b4b7b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/utils/utils.js

+9
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,15 @@ export function isBlock(node) {
780780
if (tagName.startsWith('JW-') || tagName === 'T') {
781781
return true;
782782
}
783+
if (tagName === 'BR') {
784+
// A <br> is always inline but getComputedStyle(br).display mistakenly
785+
// returns 'block' if its parent is display:flex (at least on Chrome and
786+
// Firefox (Linux)). Browsers normally support setting a <br>'s display
787+
// property to 'none' but any other change is not supported. Therefore
788+
// it is safe to simply declare that a <br> is never supposed to be a
789+
// block.
790+
return false;
791+
}
783792
// The node might not be in the DOM, in which case it has no CSS values.
784793
if (window.document !== node.ownerDocument) {
785794
return blockTagNames.includes(tagName);

0 commit comments

Comments
 (0)