Ticket #6534 (closed bug: invalid)
"doc.createDocumentFragment is not a function" error in 1.4+ when appending a function like so
| Reported by: | seasoup | Owned by: | |
|---|---|---|---|
| Priority: | Milestone: | 1.4.3 | |
| Component: | core | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
This throws an error in 1.4 and 1.4.2 but not in 1.3.2. Didn't test 1.4.1
Test Case: <html> <head> <script src=" http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script>
var Dialog = function() {
$('body').append(this.loadingDialog);
};
Dialog.prototype = {
'loadingDialog': function () { return 'foo' }
};
var car = new Dialog();
</script></head><body></body></html>
The above code results in doc being a Window object below
fragment = doc.createDocumentFragment(); line 4373
which breaks it. Putting the following in front of it seems to fix it, but I don't know all the repercussions.
if (doc.constructor === Window) {
doc = document;
}
Wrapping
var car = new Dialog();
in a $(function () {} fixes it too.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

The new Dialog() constructor happens outside a .ready() handler. jQuery doesn't guarantee it's ready until then. Perhaps it worked in 1.3 but it wasn't guaranteed.