-
Notifications
You must be signed in to change notification settings - Fork 111
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
Use full hierarchy when determining the browser default styles #106
Comments
The proposed solution is mentioned in #104 (comment) |
I think we should be limiting that effort to reach up. Maybe we could chunk the element's prototype name and see if the element is "similar" to its parent:
|
Is that better than just doing a concatenation of the |
It wouldn't work for the ポケットモンスター (see the The W3Schools list is also missing SVG elements which is an avenue of weirdness all unto its own. My solution wouldn't work for Your suggestion would be a start. I personally think we could cache default styles without accounting for hierarchy e.g TD.TR.TBODY.TABLE getting cached as TD |
I'll admit that I never really attempted to target In the meantime, I'm going to make a trial to see if I can resolve the original issue this way, and then optimize down to the simplest solution that works. :) |
Looks like the best canonical list of stop tags is Block Level elements... for |
That list, if we add |
POC works! See https://jsfiddle.net/ae1m6b5v/4/ (which has the updated source embedded) |
This ensures that browser-stylesheets that have parent tag based rules work correctly. This is evident when doing (for example) a bare `TD` before, the default style was defaulted to be `padding: opx`, but when the `TD` is actually created as a child of the normal hierarchy (e.g. `TABLE`, `TBODY`, `TR`, `TD`) then the defaulted padding is `padding: 1px`. Refactored a bit for clarity Resolves #106 and thus also Resolves #95
Use case: description, code
Per the original reported problem of #95, and the discoveries made while moving towards a solution in #104, we know that the only reasonable way to get the full defaults of a particular element is to generate a matching DOM element hierarchy in the sandbox such that (for example) a
TD
in aTR
in aTBODY
in aTABLE
in aDIV
inBODY
would need all the intervening elements created in the sandbox and then we could insert the element we need now to determine its in-situ default styles.Expected behavior
Insert a
TD
and see the default1px
style that would have been driven by the fact that it's nested in aTABLE
with aTBODY
with aTR
Actual behavior (stack traces, console logs etc.)
On Chrome, they default style of a bare
TD
inserted as a direct descendent ofBODY
lies and says that its padding is0px
instead of what would actually be a1px
padding due to thetable-cell
display.Library version
2.13.1 and 3.0.0
Browsers
The text was updated successfully, but these errors were encountered: