You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having an element with a CSS property break-before set to region, always or all breaks the polyfill in most cases. What happens is that extractOverflowingContent will correctly detect the element that has this property, upon which it decides to make the cut right before it. However, it only does this if it is not the "first" element (in the region). However, the current check only picks out very specific use-cases, and misses most.
The end result is that all regions are empty, except the last, because the algorithm could not move the content further and put it all in there.
The cause
The moment a single region can not contain all of the content (for whatever reason) extractOverflowingContent is being invoked. Once a suitable cut-off point has been detected, it will then traverse the content in the region bottom-up in order to detect any elements which have a break-before property set (or others, but that is irrelevant here).
However, this is not correct. The range's endContainer is (unless we are in a single region-spanning element) very likely not the element with which this region's content starts.
Possible fix
Interesting enough, a variation of this check is performed earlier in the code, in the layoutContentInNextRegionsWhenReady-method. Here the following code is used:
This value for the first element (seen on line 130) is indeed the first element of the region and should most likely also be used by the extractOverflowingContent-method.
The text was updated successfully, but these errors were encountered:
RonaldTreur
added a commit
to RonaldTreur/css-regions-polyfill
that referenced
this issue
Dec 7, 2020
What goes wrong
Having an element with a CSS property
break-before
set toregion
,always
orall
breaks the polyfill in most cases. What happens is thatextractOverflowingContent
will correctly detect the element that has this property, upon which it decides to make the cut right before it. However, it only does this if it is not the "first" element (in the region). However, the current check only picks out very specific use-cases, and misses most.The end result is that all regions are empty, except the last, because the algorithm could not move the content further and put it all in there.
The cause
The moment a single region can not contain all of the content (for whatever reason)
extractOverflowingContent
is being invoked. Once a suitable cut-off point has been detected, it will then traverse the content in the region bottom-up in order to detect any elements which have abreak-before
property set (or others, but that is irrelevant here).It does so by executing the following code:
css-regions-polyfill/src/css-regions/polyfill.js
Lines 538 to 560 in d40c91b
Its attempt to not cause this issue can be found on line 543, where it is trying to make sure this is not the first item:
css-regions-polyfill/src/css-regions/polyfill.js
Line 543 in d40c91b
Determining the first item is done on line 539:
css-regions-polyfill/src/css-regions/polyfill.js
Line 539 in d40c91b
However, this is not correct. The range's endContainer is (unless we are in a single region-spanning element) very likely not the element with which this region's content starts.
Possible fix
Interesting enough, a variation of this check is performed earlier in the code, in the
layoutContentInNextRegionsWhenReady
-method. Here the following code is used:css-regions-polyfill/src/css-regions/polyfill.js
Lines 130 to 139 in d40c91b
This value for the first element (seen on line 130) is indeed the first element of the region and should most likely also be used by the
extractOverflowingContent
-method.The text was updated successfully, but these errors were encountered: