Skip to content

[FIX] ensure <br> is never identified as a block #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,15 @@ export function isBlock(node) {
if (tagName.startsWith('JW-') || tagName === 'T') {
return true;
}
if (tagName === 'BR') {
// A <br> is always inline but getComputedStyle(br).display mistakenly
// returns 'block' if its parent is display:flex (at least on Chrome and
// Firefox (Linux)). Browsers normally support setting a <br>'s display
// property to 'none' but any other change is not supported. Therefore
// it is safe to simply declare that a <br> is never supposed to be a
// block.
return false;
}
// The node might not be in the DOM, in which case it has no CSS values.
if (window.document !== node.ownerDocument) {
return blockTagNames.includes(tagName);
Expand Down