Skip to content

finalPropName.js: emptyStyle undefined for document generated by in-browser XSLT #4730

@sdh4

Description

@sdh4

Description

src/css/finalPropName.js defines a variable:

var cssPrefixes = [ "Webkit", "Moz", "ms" ],
	emptyStyle = document.createElement( "div" ).style,
	vendorProps = {};

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 the emptyStyle 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions