The Downloading jQuery page has out-of-date information about building jQuery with ant, which hasn't been possible for a while now. (or at least the xml files are not part of the normal distribution).
The problem: for 1.4.4 there was a commit that ditched sourceIndex when sorting nodes. This turns out to be disastrous for IE performance (as in 2% of previous speed) as demonstrated in this jsperf test. It was done for the following stated reason:
Both the createRange and sourceIndex code branches failed on disconnected DOM nodes, nodes in separate DOM documents, and nodes in non-HTML documents.
However no unit tests were added for these conditions and in testing disconnected DOM nodes I found that there is still no "solution" to sorting disconnected DOM nodes. Even after this change, every browser not only sorts differently from each other, but will in fact sort the nodes differently even upon refresh within the same browser. So obviously we can throw out disconnected DOM nodes as a justification for this performance hit.
That leaves separate DOM documents and non-HTML documents. I'm not even sure how to begin testing that! What I'd like to see, ideally is unit test cases for these scenarios that will break in 1.4.3. Using those tests we could at least refine a plugin to address this massive performance degradation with the hope that our beloved sourceIndex could someday return to the core as a prodigal son!
Hey, we're trying to eke out some more performance from our jquery app, and we noticed that virtually none of our html insertions pass the test to take the innerHTML shortcut and instead are forced to take the .append route which can in some cases double the time of the insertion.
In looking at the test we noticed that .html simply reuses the rnocache regex rather than having it's own specialized "innerHTML vs .append()" regex, and also that the regex takes somewhat of a sledgehammer approach to incoming strings.
In particular, must we use .append for all strings that contain any "<option" ? In the comment in buildFragment() it says that options are excluded because they'll lose their selected state when cloned, which doesn't apply to innerHTML.
However, "<option" can not be innerHTML'ed into a "<select" in IE, so we actually do need some test. I'd recommend that we test the .nodeName of the html injectee to see if it's "SELECT" before we ban "<option" from being inserted. This would also require separating out rnocache for use only for it's named purpose and using an rnoinnerhtml (or somesuch) for the regex regarding whether innerHTML can be employed.
Also, are there actually problems with innerHTMLing <embed and <object ? Googling seems to turn up anecdotal evidence that there's no problem with using innerHTML for these strings.
Finally are there advantages of using .empty().append() instead of innerHTML? The .html() comments imply that innerHTML is preferred, and in my own code innerHTML is better performing, but perhaps I'm missing something?
I'm trying to parse a json string that's just over 2MB long, and when I get to line 507 of jquery 1.4.2 (inside parseJSON commented with: "Make sure the incoming data is actual JSON") I'm getting an internal Firefox error: "script stack space quota is exhausted".
When I hack the code to skip that if statement, everything returns hunky-dory. My question/suggestion is that we skip that test, at least where window.JSON.parse is set. If using either a browser compiled version or the json.org version an error will be thrown if invalid JSON is encountered, therefore, we could rewrite the code thus:
// Try to use the native JSON parser first
if (window.JSON && window.JSON.parse) {
try {
return window.JSON.parse( data );
} catch (err) {
jQuery.error( "Invalid JSON: " + data );
}
} else {
if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
This way it only runs the valid json script if it's forced to use the relatively unsafe "eval" code, as opposed to running it each time, even if it's just going to go out and immediately validate it again with the compiled JSON parse.
In IE 8 (haven't tested other version of IE - works fine in FF3.6), the style will be stripped in line #4058 of 1.4.1, which is where it passes the snippet into innerHTML.
IF you put a single linebreak into the textarea before the open style tag, it works without a problem. So you can see it's a bit delicate to reproduce, but we're definitely seeing it in the alpha release code of our jquery app which I'm trying to upgrade to 1.4.1. Bug does not appear in 1.3.x. I suggest strengthening the if statement on line 4047 to 4049 to try to trap this condition, but I don't have any suggestions as to how to do so. Here's the if statement in question:
} else if ( typeof value === "string" && !/<script/i.test( value ) && (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
We've run into a client that has some weird setup who for whatever reason (thin clients/terminal server/non-admin users, etc) is having an error when they try to instantiate Microsoft.XMLHTTP in IE6, and yet MSXML2.XMLHttp.5.0 works. We don't know why, and at this point we've stopped caring. Basically our solution was simply to try a bit harder when ActiveX is available by trying additional versions of the XMLHTTP object. For people that don't have a problem the behavior should be the exact same as in 1.2.6. What do people think of this patch? I'd like to see it (or something like it) patched into ajax.js so that we don't have to maintain a separate version. To that end does anyone have suggestions? Should I post a trac issue? -Charles 276,308c276,278 < < // a helper method for retrieving a working xmlhttp request < function getXMLHTTPRequest() { < var requester = false; < // Create the request object; Microsoft failed to properly < // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available < if (window.ActiveXObject) { < var aVersions = [ "Microsoft.XMLHTTP", < "MSXML2.XMLHttp.6.0", < "MSXML2.XMLHttp.5.0", < "MSXML2.XMLHttp.4.0", < "MSXML2.XMLHttp.3.0", < "MSXML2.XMLHttp"]; < for(var i = 0; i< aVersions.length;i++){ < try { < requester = new ActiveXObject(aVersions[i]); < return requester; < } < catch (error) { < continue; < } < } < } else if (window.XMLHttpRequest) { < // Firefox, Opera 8.0+, Safari < requester = new XMLHttpRequest(); < return requester; < } < < throw new Error("XMLHttp object could be created."); < } < < < var xhr = getXMLHTTPRequest(); ---
Hi all, the application I'm attempting to write couldn't be simpler: I want to display rows of data, retrieved from a database and allow people to edit or delete those rows and add new rows. Backend is PHP, but I'd prefer to keep that out of the picture. So far I'm passing my rows successfully to jquery and have the loop ready to go, but I'm not sure how to proceed. Here's my dilemma: what's the best strategy for keeping the HTML out of my Javascript as much as possible? The whole point of this excercise has been to try to extricate as much PHP as possible from the display logic, but just subbing in javascript is obviously pretty pointless. One strategy I'm toying with is having an HTML "empty row" in the normal layout that's hidden and get's cloned for both existing and new records. Is this a common technique? Are there better ones? I'm trying not to re-invent the wheel here! TIA, Charles
Hi all, I'd like my application to be able to check my ajax results for an array with an index of "error" before it gets passed along to whatever function made the call to finish doing whatever it's doing. It looks like this would be easy if global events were called before local events, but as that's not the case, I was wondering what a work- around might be? One idea that occurs to me it to trigger the ajaxError event with my (otherwise successful) results. Is there anyway to raise an ajax error? The only other solution I can think of would be to pass back a callback function with my results, so that on a global ajaxSuccess it would look for the error index, and not finding it would call the success index, and pass the data though? Is that the way to go? Any other suggestions? TIA, Charles
I've bugged it here: http://jquery.com/plugins/node/787 and here: http://dev.jquery.com/ticket/1870 but I'm wondering if any one has any ideas for a workaround (other than switching browsers unfortunately) . Basically, in IE6 the width() on a select box (or it's surrounding div/span) is not updated when wide options are added to the select. It works great in Firefox, but that doesn't help me too much. The basic problem is this. I have a row of select boxes that need to be of minimum widths (ie. no defined width). Then at the end of this row there is a "subtotal" column, all of which works fine. Except that below these rows I'd like to have a total column that is aligned with the subtotal columns. All of this would be trivial of course if I used tables, but for various reasons the layout must remain div based. Any suggestions?