-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Showing element with jQuery does not update display style #994
Comments
This seems to be because we do not have default stylesheets which mark |
Simplified test case (for jsdom) "use strict";
var jsdom = require("../..");
exports["div should have default element stylesheet"] = function (t) {
jsdom.env('<script src="file:///' + __dirname + '/files/jquery-2.1.3.js"></script>',
{
features: {
ProcessExternalResources: ["script"]
},
done: function (err, window) {
t.equal(window.$('<div>').appendTo('body').css('display'), 'block');
t.done();
}
});
}; In comparsion to a browser: <!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
<body>
<script>
console.log($('<div>').appendTo('body').css('display'), 'should be block');
</script>
</body>
</html>
|
Wow, nice find @Sebmaster in root-causing the bugs in play here. I wonder how we can do this. There will presumably be some trickery involved in making cssstyle aware of default style sheets, without having to insert them into the document (which causes observably different results). See also domenic/html-as-custom-elements#27 |
Ran into this issue today myself. How about adding a style element to the head of the generated document, which has a set of rules that emulate the default style sheet used by common implementations? What do you think? |
No, that would break any code that looks at e.g. Someone needs to test whether default stylesheets affect the results of |
Thanks for clarifying, sorry for my clueless response above. Tried it out in chrome, safari and FF on OSX var a = document.getElementById('foo')
window.getComputedStyle(a).getPropertyValue('display')
>> "block"
a.style.getPropertyValue('display')
>> null so it looks like it shows up in getComputedStyle. I'll pull down the source and mess around with it for a bit, will send up a pull request if I can get it working. Thanks! |
Also simplify some getComputedStyle tests while there.
Fixes jsdom#994. Also simplify some getComputedStyle tests while there.
I cannot 'show' an element with jQuery?
The text was updated successfully, but these errors were encountered: