$.data() vs. $.fn.data() vs. HTML5 data attrib
I have spent time looking at the data() methods internals -- ($.data() vs. $.fn.data(). I noticed that the retrieval for HTML5 attributes is really triggered by $.fn.data() and once retrieved and added to the cache, yes $.data() will have access to it. I wonder why the trigger to retrieve HTML 5 attributes was not done at the lower-level $.data() method that way it would be trigger by either form of data(). Am I missing something? ceo
$.inArray
should the inArray function change to be consistent with different browsers? for example shouldn't we change return array.indexOf( elem );to something similar to var ret = array.indexOf( elem ); return (ret==undefined)?-1:ret;or even add a check if ret isNAN ?
.data() type conversion
I found an issue with using .data() to access data-* attributes and how it does automatic type conversion. The conversion will break any string that just happens to look like a JavaScript value. A simple example: HTML: <div id="foo" data-version="1.0">...</div> JS: jsversion = $("#foo").data("version"); jsversion is now the number 1. That is totally wrong if you intend to use that attribute as a string. (I was using it to create a URL where "1.0" is the valid value.) You can get around
javascript culture
I know that every language has its own culture, the culture of JavaScript is definitely unique. I am a big fan of jQuery, but I have mixed feeling in the implementation of jQuery core. The passed in parameters get reused and overloaded for semantics in many places, is it part of javascript culture. I know this might help to improve performance, but I don't know the actual performance gain, but the cost of maintenance will definitely increase. I have changed dataAttr function in data module of
jQuery.cache
I know that jQuery.cache object is used to implement the data api. I feel it is little in secure to expose to outside, for example, external script could easily break our app, by using jQuery.cache = null Should it be encapsulated in side the closure, so that it would not be temper. Thanks Fred
Animations should (temporarily) override min-height and min-width
When animating, jQuery of course overrides width and height (as well as forcing overflow:hidden). If you have a min-height or min-width though, jQuery doesn't reset that--it really ought to, so you can, say, .slideDown() an element that when visible, has a min-height. Here's an example: http://www.babywhale.net/jquery/minheight.php I run into this one a lot more than you'd think! :)
bugfix for jquery-1.4.2, internet explorer 8, jquery.fx.step()
Hi. I'm developing a free web component, http://mediabeez.ws/lah, which runs into a startup problem when viewed in IE, caused by jquery. The thing crashes due to a "invalid argument" error. I hereby propose the following fix; jquery-1.4.2.source.js: line 5892 and further: old code: step: { opacity: function( fx ) { jQuery.style(fx.elem, "opacity", fx.now); }, _default: function( fx ) { if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
Closure Compiler Extern File
I'm using jQuery in a project where other code is compiled with Closure Compiler using advanced optimizations. The compiler project currently doesn't have an extern file for jQuery 1.4.2. Since Closure Compiler is now the minification tool used, is there an extern file already written? If not, I'm more than willing to write it or to participate in the process. See http://groups.google.com/group/closure-compiler-discuss/browse_thread/thread/7ae427c15e2bf2e9 Chad Killingsworth
Importing jQuery 1.4.1 into greasemonkey scripts generates an error
Hi, I realise this is more of a glitch with greasemonkey rather than jQuery, but I thought I would post the info here anyway. Greasemonkey has an API called @require which can import a javascript library when the userscript is installed. http://wiki.greasespot.net/Metadata_block#.40require Unfortunately the latest version of jQuery (1.4.1) seems to be incompatible. The problem seems to be with "detecting-event-support-without-browser-sniffing" section around line 930. If you change var isSupported
elem.ownerDocument.defaultView breaks when elem == (iframe) document
in the core function curCSS (around line 4691 in jquery-1.4.2.js) jQuery attempts to access the defaultView attribute from elem.ownerDocument. This is fine and well, except for the relatively complex case where you are loading jQuery outside of an iframe, and then are trying to use jQuery from within the iframe without reloading it. There is a good reason for having a setup like this (in short, to enable an "load once - always on" connection to a server, and then using hashchanges to navigate the
getJSON does not (of course) return an XHR object for cross domain requests
Hi all, I do not know if this is the right place to ask, if not, please excuse me. From the getJSON() official documentation I can read this: $.getJSON(url, data, callback) function [CUT] Returns XMLHttpRequest but, when you have a JSONP request, the returning XHR is undefined, probably because in this case there is no real XHR object to deal with. My question is, do you plan to add some hack to jQuery in order to return a pseudo-xhr obj in this case too, want you to add a JSONP specific method without
Internet Explorer Version 4 (What)
I know, no one supports IE4 , let alone IE4 with jQuery . My sites do not give any JavaScript to IE5.5 and below in fact. My issue is, I do have a few customers that use IE4 (I know, I know) and, just like IE5.x and other old devices, they get a fully-functional linear layout. The trouble is, simply by attaching jQuery, IE4 (only IE4) throws up syntax errors. I attach my own JavaScript (fairly comprehensive, name-spaced, object-oriented) and get no errors. The IE4 issue does not cause any problems
PSEUDO
hi, i recently upgraded the jquery-core from 1.3.2 to 1.4.2. to my suprise i noticed a big slowdown. in firefox the slowdown is minor but still measurable on some pages, but in ie8 it's really big. so i used dynaTrace to have a look. the biggest difference i noticed immediatly is the number of invocations of PSEUDO. in jquery 1.3.2 it's 3678 and in 1.4.2 it's 22253. some other functions are also slower, but the difference isn't so obvious. can anyone explain this? i attached to screenshots from the
serialize() with parameter?
Hi, As the docs say, "For a form element's value to be included in the serialized string, the element must have a name attribute." I think it would be very useful to be able to specify a propery for the serialize method, so that it serializes a different property than name. In ASP.NET, the server controls have an annoying name, generated by the framework. example: <input type="text" readonly="readonly" class="required for-report clickable hasDatepicker valid" for-query-string="value-for-querystring"
Drop official support for Firefox 2, Safari 3, Opera 9, Chrome 4?
Hi everyone, I just wanted to briefly take the temperature of the group in seeing whether or not we should drop official support for some of these older browsers. There a few outstanding bugs in the bug tracker related to these browsers, some of which have been sitting for over two years without any action. Either jQuery supports these browsers, which means these bugs should be fixed…or jQuery doesn’t really support these browsers, in which case it should not say it does. (Crashes and broken document.ready
The delegate method is waste?
Here said $("table").delegate("td", "hover", function(){ $(this).toggleClass("hover"); }); is same to $("table").each(function(){ $("td", this).live("hover", function(){ $(this).toggleClass("hover"); }); }); But I think it is also same to $("table td").live("hover", function(){ $(this).toggleClass("hover"); }); Thus the method delegate is waste, right?
add a visible filter that evaluates whether an element is visible on the screen.
Ran into a problem where I needed to get a list of headers that were visible in a scrollable div. I did this to solve the issue but it seems like a useful kind of filter or something to be incorporated into the jQuery core. Thoughts? (function ($) { j = jQuery; $.fn.visible = function () { /// <summary>Filter that checks if the item(s) is visible within the page. Returns set of visible elements</summary> /// <returns type="jQuery" /> // sanity check aborts when no elements visible
bugfix : "illegal argument" in jQuery.style(), try-catch fixes it.
Hi. My CMS does some magic with the jQuery.dialog code, and apparently deepcalls jQuery.style() in a way that results in el.style[name] = 'NaNpx'. Firefox will not die on it, but IE does, nitpick that it is. It's closed source, so i won't be sharing any urls with you at this time, sorry. Anyways, the solution is another try-catch structure, starting at line 4617. Constantly fixing these types of jquery-related bugs in my CMS during development of features is timeconsuming. Many browsers, each with
Accessing text
Current implementation of .text() does not give to access the text value of a node EXCLUDING the text value of its children. Suggestion is to implement a new method, i.e. .nodeText(), that would allow accessing or changing the text of selected node(s) only, leaving children intact. Effectively, the method would operate on: $(this)[0].firstChild.textContent;
jQuery.1.4.2.js needs patch at line 1919
I had to replace line 1919-1922 in my local copy of jQuery.1.4.2.js to prevent IE 8 javascript errors when navigating away from a page using window.location.href = 'blah blah': OLD CODE ======================================================== events = jQuery.data(this, "events"); if (events) { handlers = events[event.type]; }; NEW CODE ======================================================== try { events = jQuery.data(this,
IE9 + 1.4.2.
1.4.2 fails in IE9. Solution. Instead of : // Make sure that the execution of code works by injecting a script // tag with appendChild/createTextNode // (IE doesn't support this, fails, and uses .text instead) if (window[id]) { jQuery.support.scriptEval = true; delete window[id]; } Should be : // Make sure that the execution of code works by injecting a script // tag with appendChild/createTextNode // (IE doesn't
Executing JavaScript after wrap method
Hello. I just have a problem with the wrap method of jQuery. Look at this markup: <div id="mainDiv"> <div id="innerDiv"> </div> <script type="text/javascript"> $(document).ready(function() { alert('test'); }); </script> </div> <span onclick="$('#mainDiv').wrap('<div />');">say test</span> When I insert it on my page I had very interesting results. It says 'test' when page is loaded and it is fine. Click on 'say test' span and you'll see
jQuery.inArray Easy Improvement
Since probably somebody left the Dynamic post where it is, I would like to open this new discussion about jQuery.inArray, which is basically an indexOf and which is not optimized. I simply quote myself to make things clear, Regards. ---------------------------------------------------------------------------------- Just a curiosity, are you using indexOf with jQuery instances as well? In this case line 411 of core.js <span style="font-family: courier new,monospace;"> </span><span style="font-family:
$(fontElement).parent('.className') returns undefined
$('font').parent('.dad') returns undefined. <div class="dad"> <p> <font>teste</font> </p> </div>
specification for easing functions?
Is there a formal specification for what is expected of easing functions? I see that the linear and swing functions as well as the functions in the easings plugin are written to use a start value and a delta value. But when jQuery core invokes the easing function it always passes a start of 0 and a delta of 1. What I'm wondering is whether the start and delta values are guaranteed to always be 0 and 1 (at least for jQuery 1.4 and later). If so, it would make easing functions a lot simpler, and
Catching All Errors
Hi All, My application is mostly all ajax, using jquery (of course!). Over the past few days, I've been trying to create a method to catch or trap most errors in a universal way. The idea being that when our native application-level error handling fails, the application is left in an unreliable and unknown state, so I'd like to both record as much information as possible, and reset the application (i.e. refresh the page). To do this, I need to monitor the window.onerror, and thanks to the helpful
suggestion: ultimate type for jquery
I made this, probably fastest and most accurate, type detection function http://gist.github.com/204554
$.inArray
Hi! Love jQuery. http://api.jquery.com/jQuery.inArray/ The function $.inArray just caused me alot of confusion. This was mainly because of the name. I propose a name change to $.indexOf, and the creation of a "real" inArray function, which returns true/false if element is in array. See the conversation in the comments at the docs. My second proposal is an optimization of $.indexOf. If a native indexOf exist, this function should replace $.indexOf on the first call.
Resolving syntax inconsistency between .animate() and .fadeTo()
Not only does the name .fadeTo() logically suggest that the first parameter should be the opacity value to fade to (it's actually the second parameter, the duration comes first), it's also inconsistent with .animate() which takes the form .animate({properties}, duration) that one would naturally expect. Ideally I'd like to see the .fadeTo() function/effect (and any others which are similarly counter-intuitive with regard to parameter order) revised so that the parameter order becomes as one would
Should $("#unfound").data() return null?
I found when a jQuery set is emtpy such as $() or $("#unfound") the .data() method throws an exception. I would expect it to return null. I've made a fix and committed it to my forked git repo. But I wanted to ask first if that is the correct behavior. And if so, who do I include on the pull request for little bugs like this?
How does jQuery avoid recursion with its animate function callback?
I've run the following code and looked at the stack (function() { var i = 0, max = 20, move, $box = $('#box'); move = function() { if(i < max) { $box.animate({ //some animation parameters }, move); } else { debugger; } i+=1; }; move(); })();This was run on Firefox 3.6 with Firebug. When it stops at debugger, the stack looks like it only
Expose now()
I realize that the logic in the private `now()` function is incredibly simple, but I'm wondering if it could be exposed as $.now() ... I find myself replicating it frequently (in plugins, page-init scripts, etc), and that doesn't seem very DRY. Seeing as how it's already in the core, just not exposed, it shouldn't impact the filesize of the core.
Building on Windows
I am trying to build from a clone of the git master using mingw under vista.. everything "appears" to work except that I end up with about 1100 lines in 'dist/jquery.js' that look like this :/users/daniel/apps/mingw/EXPOSE/r src/sizzle-jquery.js :/users/daniel/apps/mingw/EXPOSE/r src/sizzle-jquery.js :/users/daniel/apps/mingw/EXPOSE/r src/sizzle-jquery.js :/users/daniel/apps/mingw/EXPOSE/r src/sizzle-jquery.js when i try and do a make lint or make min i get a heap of errors because of the lines above..
Why are event handler registration methods added to jQuery.attrFn[]?
From browsing the source, I see that event handler methods like .click(), keydown(), and so on are added to the jQuery.attrFn[] array. This means that they are specially handled by .attr(): if you try to set an attribute with the same name as one of these methods, the event-hander registration method will be called instead. So far, so good; that sounds like a cool idea. I ought to be able to do things like: $("p").attr({ lang:"en", click: function() { /* handle click events */ } }); But the
Should .offset() make a defensive copy of the position object before passing it to a callback?
I recently tried to write code like this: $("h1").offset(function(index,curpos) { curpos.left += 25*index; return curpos; }); It doesn't work, if I do it that way. Instead I have to write: $("h1").offset(function(index,curpos) { return {left: curpos.left + 25*index, top:curpos.top}; }); jQuery either needs to make a defensive copy before calling the callback or the documentation needs to clearly state that the callback isn't allowed to modify the passed object. I prefer the former and
keypress event, arrow keys and webkit
Hi, I've just tried to use the keypress event for the first time. But it seems that arrow keys don't register as keypresses in webkit browsers. To see this is action visit: http://api.jquery.com/keypress/ And try the "Type something" demo. Opera/ Firefox fire events with the arrow keys but Safari/ Chrome don't. Is this expected behaviour or a bug? The page does say: Because of this distinction, when catching special keystrokes such as arrow keys, .keydown() or .keyup() is a better choice. But this
Htmlunit webclient with jquery simple source code
Hi I need, Htmlunit webclient with jquery supportting simple source code, please help me. Thanks & Regards R.Anbarasan.
Submitting a patch
I recently ran into the problem described in ticket #6368 and was able alter the 1.4.2 source code to fix it. I would like to submit my changes as a patch, however I haven't the faintest idea on how to get started. I have never contributed to an open source project before, so any help is appreciated!
Error parsing xml when name of source file does not end with ".xml"
There seems to be a problem when reading XML from a file whose name does not end in ".xml". THis only occurs when the jQuery is run from a web server; it does not happen when run locally. I will attach a .zip file with the source code I'm using as well as two versions of a very simple xml file to use - one version has a ".xml" appended to its name, the other has a ".dat" extension. Both contain exactly the same data. You can also find the file on my server here: http://www.mit.edu/~rjc/jQuery/loadXmlTest/loadXmlTest.html
Problem with selector after upgrading.
After upgrading to the latest jQuery I'm having trouble using the selector $("a.thickbox, area.thickbox, input.thickbox") which used to work before uploading. at the very least I need to select all A elements, with the class of "thickbox". can anyone tell me how to accomplish this?
Next Page