.map() argument ordering should be switched
$.map(fooArray, callback) passes arguments into the callback with the correct ordering: (value, index) $(".foo").map(callback) passes arguments into the callback with the wrong ordering: (index, value) I believe the original reason why the second one passes index first is because it is expected that the developer will just use "this" to access the element. Now that es6 lamda style functionals are being used more and more, "this" is no longer an option. Code such as the code below doesn't work because
browserWidth() and height(), compatible for desktops and smartphones (fullscreen apps)
a gift back to the jQuery developers and community :) rename it and use it as you please. feel free to include this in the jQuery core; i think it's needed there. what's also needed is a color animation for rgba(0,0,0,0.5) to rgba(255,255,255,1) for instance. you forgot to include that :) moderators of this forum, - i'm not ungrateful - i'm an opensource developer who uses a forum like this to feed back vital info to the developers of jQuery - i'm not here to advertise my product, i simply want
Evolve jQuery to be a framework and not just a library
I know this is a long shot but it seems that jQuery has been left behind by frameworks (Angular, React, Vue). Though I know that jQuery is a library but do you guys have any plans to make it so that it's going to evolve and compete against those? I'm just throwing this out there
Rename .closest()
I can't count the number of StackOverflow questions I've seen where they misused .closest(), thinking it would find the nearest sibling, cousin, etc. element that matches a selector. I think I've even seen it in places where .find() is what they want. This expectation matches the normal meaning of the function name, since closeness is not usually restricted to a particular direction. I suggest that it be renamed to something like .closestParent(), to make it clearer that it only searches through
Add optional data parameter to each function
I've come across situations where it would be nice to pass some data to the each function. As in $(myQuery).each(myFunction, myData) which would invoke myFunction(index, element, myData) for each element. A more specific example might be: $('#recordsTable tr').each(myHighlightFunction, arrayOfSelectedIds) where myHighlightFunction would examine each tr for some identifying aspect and change the background color for any row that matched a value in the array Right now, there are at least five ways
Get coordinate relative to other elements whith css transform involved
I'm thinking about a way to get coordinate of an element relative to another element when there is transform applied in between (either directly on those elements or somewhere on the dom tree). We can easily convert coordinate with the used of getComputedStyle().transform which return the matrix to apply. I have a running code doing it. We could do this way : All function would take the first element. - jQuery.toPageCoordinate() would return a function(x,y) to convert coordinate relative to element
Ajax-only build - without selector module (ideal as a lightweight ajax only build for mobile devices)
Right now, when doing a special jquery build, you must always include the selector module, no matter what the build is: "Any module may be excluded except for core , and selector . To exclude a module, pass its path relative to the src folder (without the .js extension)." There seems to be a common desire out there to only use the ajax part of the jquery library: http://stackoverflow.com/questions/4132163/is-there-only-ajax-part-of-jquery Right now, this is semi possible, if you build jquery
How about having method like getAllElementsInArea(x,y,width,height)
For method like getElementsAtPosition(x,y) which return us DOM elements of specific positions. Instead of a specific location can we have given area (may be a rectangle or circle radius from x,y). So it should look something like getAllElementsInArea(x,y,width,height) . To get elements from screen from a given area.
parent and parents DOM selector method names
Why do we use the parent method to select the immediate parent of a DOM object and parents to select its ancestors? This implies that there can be parallel html tags that act as a parent of a html tag. Which is not the case unless I am missing something. Why not use parent and ancestor instead?
Feature Request: Public Event Listener List
Hello, This is a very old topic, however, I would like to blow off the dust and start a fresh discussion on the matter. I will start with a story of a front end developer, lets call him Bob. One day Bob was wondering around in the magical jQuery Forrest when he had a nice little idea for a plugin. Bob wanted to create a simple/customizable way to ask a user for confirmation before the default events take place on an object. Here is a real world scenario. We have a "Delete Button" ... it has a click
Applying styles to :before and :after elements
This seems like something that should be fairly trivial: $('.foo:before').css('margin-top', '50px'); But currently does not work. There's no reason this coulnd't be implemented in this way: 1) Create a stylesheet on the page 2) Add a style for .foo:before and use the css rules provided
Allow * wildcard in .removeClass()
It would be nice to be able to use the * character as a wildcard in calls to .removeClass(). For example, elem.removeClass('foo-*') would remove all classes that start with foo-. Currently, the easiest way to do this seems to be the following, which is neither elegant nor efficient: .removeClass(function (_, cl) { return cl.split(' ').filter(function (c) { return c.substr(0, "foo-".length) === "foo-"; }).join(' '); })
jQuery event listener-Continuous or Live
I have my input elements and their change events to handle some display. After loading page, When input values are changed through some other jquery functions...I do not have a way to know the values are changed. Please note that I can not change or do anything with that other jquery function which changes my input values. It is not in my control. Can we have something in jQuery API which continuously keep checking or listening any changes happened to the html elements through external/internal uncontrollable
Proposal of an extension to jQuery core for async loading and module definition.
Hello friendly jQuery people! Please excuse this rather long mail. I'm writing on it and the docs for the better part of this day. (And excuse the word "mail" and the formating in the following. I thought there was a mailing list to post it to. Now I'm feeling a little old school while pasting it in here ;) Quicktip: There is documentation and code at https://github.com/ScheintodX/jqinit.js if you which to skip my writing and just have a peek. I'm the author of jqinit.js and would like to propose
jQuery.event.trigger() : Pass the "event" object as an argument to "elem[type]()" call
In function jQuery.event.trigger(), there is the following call (l. 4357 in jquery-2.1.1.js) : elem[ type ](); why not pass the event object as an argument ? This way : elem[ type ](event); This would provide the event object to the called function which is usually essential. In my case, this would allow to retrieve the namespace and thus adapt the action.
$.isJson(str);
Why do not implement this function, that already exists in Prototype.js ? I actually don't know how to implement the script on the core, so, here is the snippet. This script implements $(object).isJSON, $.isJSON(object) and [String].isJSON() functions Feel free to fix any bug. (function ($) { $.isJSON = function (json) { json = json.replace(/\\["\\\/bfnrtu]/g, '@'); json = json.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'); json = json.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
findExclude(), a descending traversal method with functionality similar to parentsUntil
Hello, first time contributor looking for feedback. I ran into some issues where selectors were not the right tool for filtering nested elements and noticed a few cases of this around the internet. Primarily I see this in situations where people use $( selector ).each() for things like: Search within a container class which may have the same type of container nested within, as in my example with "Messages" - for form message threads. Searching by tag with nested ul/ol/table when each depth is meant
wish to be more intuitively object-oriented
i have started to use jQuery since the very first edition and i have read the code in detail of nealy all the versions of jQuery. The code is concise but not intuitively object-oriented enough. It must be a great help if we can make code more intuitively OO. And i think this idea will help us much. please refer to http://classjs.org which works to make js intuitively OO.
Suggestion: $(element).addTo(set)
I'd like to suggest an addTo() method, since jQuery often has two methods to do the same task but switching the context between source and target. For example, these could be equivalent: // Add to set using $.fn.add (function ($) { var $set = $('#a, #b, #c'); $set.add($('#d')); })(jQuery); // Add to set using $.fn.addTo (function ($) { var $set = $('#a, #b, #c'); $('#d').addTo($set); })(jQuery); Example implementation: $.fn.addTo = function (collection) { $(collection).add(this);
Matchers and pseudos
Selector matching happens rtl, but I think there's a case to be made in the case of filters this isn't exactly best. Each part of the selector operates against an element and all of the simple selectors in CSS are, well, simple to check. Filters, however, don't have to be - the complexity of a filter is kinda N. Here's an example: .foo .thinger:_custom(.a .b:matches(.y:odd, span .x:even), .foobar) The filter above involves a lot of complexity. If the filter is subject as in the above case,
Allow .html() to be used on Shadow DOM
The Shadow DOM currently allows for the .innerHTML property to be used to modify the HTML. Is it possible to add this functionality to the .html() method in jQuery?
X-XSS-Protection "1; mode=block" in Safari (4.x, 5.0) with jQuery 1.9.x redirects to "about:blank"
Hi there, in the ticket http://bugs.jquery.com/ticket/13546 (closed as "notabug") I described in comment 3-5 what caused this issue. This seems to be a bug in the XSS handling in WebKit. Does anyone here has some detailed information about how this works? I found nothing (I am interested in what is investigated when) and could only workaround by trying over and over again (and finally changing the line in jquery.js which does not feel right to me). I never encountered such an issue before but now
toggle(function)
$(selector).toggle(function) should be equivalent to $(selector).each(function() { $(this).toggle(function()); });
Requesting a way to prepend an event handler
Hi, I'm reposting this from http://forum.jquery.com/topic/requesting-a-way-to-prepend-an-event-handler, which did not get any responses. It appears that all of the event handler adding functions (on(), one(), etc) append to the list of handlers. This can make it difficult to override other handlers that are already registered. Could jQuery add a way to prepend to the handler list? My use case is that I am creating a separate implementation of this jQuery-based drag/drop library: http://threedubmedia.com/code/event/drag
More exact use of the Slider
On smaller screens or sliders, it is not easy to pinpoint a slider value. You may say that it is not meant for that. However, I would argue that it could well be used for that with a modification. Here is an example: Before: Slide the slider to where you want to be. The feedback may show a number like '50'. Lift your finger. The feedback now changes to '49' or anything but '50'. Result: :-( After the mod: Slide the slider to where you want to be. The feedback may show a number like '50'. Keep
Save the jQuery factory, reuse it in frames, no 2nd network request
Yes, there are those who hate frames with all their souls. If you're one of them, you probably won't like this idea at all. But if part of the page never or rarely changes, and you think frames make sense in that situation, you probably won't reject this idea on religious grounds. Terminology: The jQuery script tag doesn't contain jQuery. It contains the jQuery factory, which looks like this: (function( window, undefined ) { ... var ... // Use the correct document accordingly
feature request: debounced resize event
People designing responsive sites drag their windows wide and narrow like mad accordionists! But Doing this without debouncing the resize event can causes chaos in the console. So I use a debounced resize event on almost every single page I ever design. Louis Remi's longstanding solution: https://github.com/louisremi/jquery-smartresize is a good candidate for canonization into core, in my humble opinion, possibly streamlined slightly. It's not a "plug-in" really, it's a abstraction to resolve a persistent
An advanced selector request $.level()
I was thinking on a tool that would make people's life easier by making a recursive search of elements and give us the deepest level when plainly used. Level 0 <div id="test"> Level 1 <div> Level 2 <div class="third"> Level 3 <div> Level 4 </div> </div> </div> </div> It should return level count when no index is given; $("#test").level(); // Which should
feature req: .until()
I was wondering if it's feasible to add an "until()" method that is identical to the existing "prevUntil" and "nextUntil", except it will determine the direction to traverse for you based on the index of the supplied parameter. I realize this may get a little complicated when passing a jquery object or selector that has multiple matches, in which case I'd imagine it would use the first result. Furthermore, an "untilAfter()" that the same as the proposed "until()" but also includes the parameter
Online tools for extracting only required modules from core jQuery
Hi Team! I gone through the process of extracting the required modules from core jQuery. But found difficult to use it. Can we have (1): an online tool where all the modules from core jQuery listed at one place each modules will have checkbox next to it after selecting some modules, user will be able to export those modules WITH their dependent functions so that user will visually get ONLY required modules in minified form Or can we have (2): an online tool where all the modules from core jQuery
Passing hash to $.fn.toggleClass
Similar to .attr and .prop $('body').toggleClass({ editable: true, allowThing: false })
jQuery.now() to comply with the "High Resolution Time" API.
jQuery.now() is a useful function. It can be more useful. I would add a boolean operator that will allow to change the default behavior ( (new Date).getTime() ) to be performance.now() as per the High Resolution Time W3C Recommendation. What do you think?
Why not add timer functionality to the core?
It seems to be that jQuery is all about taking what you can already do in JS in browsers, and wrapping it to make it a lot easier. To that end, timer functionality would seem to be an ideal thing to add to the jQuery core. You could have named timers, or timers associated with individual DOM elements. I could just refer to a timer by name, for example: $.timer("redCountdown").start(); $.timer("redCountdown").changeInterval(123); $.timer("redCountdown").stop(); Or have a timer associated with DOM
jQuery builder
Hi, I try to develop for a customer some WebWorkers to made some ajax request. The problem is that I can't load jQuery because it try to plug on the window object. And often, I use jQuery only for the DOM ready event and to send some Ajax requests (and use some utilities function, like isFunction, noop ...). Can we have a builder, where we can choose what part of the core we want to load (core, utilities, ajax, manipulation, transformation, animation ...) ? And this builder can have an option where
And what is with JSON?
JSON found in many usage, as well as me. Thats nice about that getJSON or parseJSON a JSON string is converted to an object, but what about the other direction? Constantly (and especially if you are constantly working with JSON) you have to make sure that you use a reasonable parser - Because if you want to convert objects to JSON, one must necessarily use a plugin. Why is this not built into the core?
.exitIntercept()
I'd like to submit my very simple solution/replacement for the deprecated .beforeunload() utility. jQuery.exitIntercept = function(e,msg) { var message = jQuery.trim(msg); e = e || window.event; if (e) { e.returnValue = message; } return message; } This small utility is IE/FF/Chrome/Safari safe. Thanks Usage: window.onbeforeunload = $.exitIntercept("You are attempting to leave this page with unsaved changes! If you leave this page without saving your changes, they will be lost!");
Proposal for Official .ScrollTo() Method
I wrote this .scrollTo() method to make scrolling much simpler. I hope it can be included in the next iterative release, as part of, jQuery's core library. I appreciate any feedback. API / Examples / Source: .scrollTo()
Why not make jQuery a core script engine to the browser without parsing it by JavaScript as a library?
I would like to know if the developers of jQuery ever considered the library to work like the V8 JavaScript engine rather than as a JavaScript library. Considering that everything is being re-done over and over by the next parser: myscript - jQuery (doing what myscript was trying to do, just the harder and longer way) - JavaScript (again repeating the same) - Browser (again..., to other underlying libraries) - OS that then eventually directs the entire machine on executing the command, which responds
New $.Callbacks object behavior
I've modified the private fire function of Callbacks object to recognize the string return value "remove". Each callback that return "remove" will removed of the current list. I don't know if it's the best way to do this, but it's an idea.
Feature reques: toggle attribute
usecase: function onclick(){ if(expression == true){ $("#myselector").attr("checked","checked"); }else $("#myselecto").removeAttr("checked"); }So, maybe better add $("myselector").toggleAttr("checked","checked");
Next Page