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
finalPropName.js: emptyStyle undefined for document generated by in-browser XSLT #4730
Comments
Thanks for the issue. We currently don't have any XHTML testing setup, not to mention including XSLT transformations. Is that the only place that requires modification? I'm a bit afraid of going this route if this requires changes in many more places, especially as long as we don't test it. |
Looking at the patched jQuery that you provided, it also includes dropping one workaround for Android Browser that we still need in the 3.x line: |
Thanks for looking at this! I didn't do any exhaustive searching or broader testcase for related problems but the link in the previous comment does highlight the one other case that I stumbled across that affected what I was doing. In that case the variable "style" may be null in which case the highlighted code will error out when extracting style.width Any call to document.createElement() as opposed to document.createElementNS() has the potential to create an element with a null .style attribute. Likewise any access to the .style attribute of an element has the potential to be null. So: Simply fixing the definition of emptyStyle in finalPropName.js will fix a lot and will stand on its own. But my testcase still doesn't work in that case (more discussion below). A little bit of grepping through the source indicates that the total number of calls to createElement() and references to the .style attribute is reasonably small. Here is the testcase with the emptyStyle definition fixed: http://thermal.cnde.iastate.edu/jqbug_halffixed.xhtml Why is pixelBoxStyles undefined?
In the xslt/xhtml environment div.style from document.createElement() is null so the remainder of the function (which is what assigns support.pixelBoxStyles) never gets executed. Realistically fixing all these things might be more than is desired in a stable release. Nevertheless the emptyStyle fix and perhaps modifying curCSS() to accommodate a null support.pixelBoxStyles are low risk. Since the total number of calls to createDocument() or the element .style attribute is not all that large a broader fix does not look like it would be a lot of work. Thanks! |
@sdh4 would you be willing to make a PR with your proposed fixes? |
Should I do just this focused issue (emptyStyle undefined) or attempt a
broader fix? I must admit I'm not in much of a position to test the
broader fix, but it shouldn't be difficult to write.
…On Mon, 2020-08-31 at 09:46 -0700, Timmy Willison wrote:
@sdh4 would you be willing to make a PR with your proposed fixes?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@sdh4 Isn't all of this fixable by changing all occurrences of Ideally, we'd have this tested as no tests mean we may regress any moment, even before we manage to release the fix. Such testing would be done via Karma by adding another target to the If you're willing to spend some time on adding such a test coverage, I'd be willing to help, guiding you through the process & helping if you get stuck. But, anyway, a good first step would be just a PR with source modifications for us to see how big this change would need to be. |
Description
src/css/finalPropName.js defines a variable:
that is used to do CSS property name translation. Under Chromium (tested v81) and Firefox (tested v76) if the document was loaded via an in-browser XSLT transformation then
document.createElement( "div" ).style
is undefined and attempts to use theemptyStyle
variable in the remainder of the finalPropName code fail.Recommended solution: Change emptyStyle line above to
emptyStyle = document.createElementNS("http://www.w3.org/1999/xhtml", "div" ).style
. This seems to work regardless of whether the document is XSLT or XML or not and in both Chromium and Firefox.Link to test case
(Simple XSLT transformed XHTML. The transformation used is a no-op.)
http://thermal.cnde.iastate.edu/jqbug.xhtml (You will see an error in the browser console). Compare to http://thermal.cnde.iastate.edu/jqbug_fixed.xhtml (Difference is a patched jquery with above fix in place plus another patch based on current master branch)
The issue with .style being undefined is easy enough to demonstrate. Load either of the above test case URLs. In the Chromium/Chrome console enter:
document.createElement( "div" ).style
. It will show as undefined. Then try entering:document.createElementNS("http://www.w3.org/1999/xhtml","div").style
and it will give the correct object.The text was updated successfully, but these errors were encountered: