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
If there is an element with a CSS property break-before or break-after that also contains children, whose content ends up being split by the extractOverflowingContent-method, the algorithm will ignore the value set to this breaking-*-property.
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).
// find the nearest ancestor that has a previous sibling
while(!e.previousSibling){
// but bubble to the next avail ancestor
e=e.parentNode;
// dont get over the bar
if(!e||e==region)returnnull;
}
// return that sibling
returne.previousSibling;
},
It will return the previous sibling, unless it has none. In that case it moves up to its parent and returns its previous sibling. This however means the the actual parent-element is completely ignored. And this is why the problem described above occurs.
If the table ends up overflowing a region, then a TR-element will end up being the target from which the algorithm will start looking for elements with a break-*-property set.
However, the getAllLevelPreviousSibling-method will skip over the table-element and move directly on to the paragraph preceding it. In effect, the table will not end up being moved to the subsequent region, it will be cut in two instead.
Possible fix
Taking the actual parent element also into account, instead of skipping it, should resolve this.
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
If there is an element with a CSS property
break-before
orbreak-after
that also contains children, whose content ends up being split by theextractOverflowingContent
-method, the algorithm will ignore the value set to thisbreaking-*
-property.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
The backward traversal happens by invoking a helper-method
cssRegionsHelpers.getAllLevelPreviousSibling
on line 560:css-regions-polyfill/src/css-regions/polyfill.js
Line 560 in d40c91b
This method is pretty straightforward:
css-regions-polyfill/src/css-regions/lib/helpers.js
Lines 17 to 33 in d40c91b
It will return the previous sibling, unless it has none. In that case it moves up to its parent and returns its previous sibling. This however means the the actual parent-element is completely ignored. And this is why the problem described above occurs.
An example
Let's say we have content that looks like this:
and some styling that looks like this:
If the table ends up overflowing a region, then a TR-element will end up being the target from which the algorithm will start looking for elements with a
break-*
-property set.However, the
getAllLevelPreviousSibling
-method will skip over thetable
-element and move directly on to the paragraph preceding it. In effect, the table will not end up being moved to the subsequent region, it will be cut in two instead.Possible fix
Taking the actual parent element also into account, instead of skipping it, should resolve this.
The text was updated successfully, but these errors were encountered: