Live data from Hacker News

jQuery 3.0 Released

jquery.com

41–50 of 164 posts

Re: jQuery 3.0 Released

#41

Earlier quoted context omitted.

True. Although whenever I see a jQuery plugin like that I try to replace it with some combination of "components" [1]. There is a lot of progress in that area. There are stuff like : File picker [2], dropdown [3], tip [4] for tooltips and many more. 1 : https://github.com/component 2 : https://github.com/component/file-picker 3 : https://github.com/component/dropdown 4 : http://component.github.io/tip/

The dropdown and tooltips look useful, but FYI it's really simple to make a file picker. Just put a hidden input type="file" on the page, then: document.getElementById("that-element").addEventListener("change", function(e) { // e.target.files }); document.getElementById("that-element").click();

It's not so easy

    document.getElementById("that-element").click();
doesn't exist. You need to use something like

        /** Creates the click on the input */
        const clickEvent = document.createEvent( "MouseEvents" );
        clickEvent.initEvent( "click", true, false );
        document.getElementById("that-element").dispatchEvent( clickEvent );
References :

1 : https://developer.mozilla.org/en-US/docs/Web/API/EventTarget...

2 : http://stackoverflow.com/questions/6367339/trigger-a-button-...

EDIT ( sorry can't reply to you, because HN ) :

Relevant jQuery discussion

3 : https://github.com/jquery/jquery/issues/2476

Re: jQuery 3.0 Released

#42
post #19
post #3

http://youmightnotneedjquery.com/

I'm surprised that there's no youmightnotneedprintf.com

I'm surprised you are comparing jQuery (a non-trivial additional dependency with reasonable dependency-less alternatives) to printf (a small piece of a dependency you most likely pull in already with).

Re: jQuery 3.0 Released

#43

Earlier quoted context omitted.

The dropdown and tooltips look useful, but FYI it's really simple to make a file picker. Just put a hidden input type="file" on the page, then: document.getElementById("that-element").addEventListener("change", function(e) { // e.target.files }); document.getElementById("that-element").click();

It's not so easy document.getElementById("that-element").click(); doesn't exist. You need to use something like /** Creates the click on the input */ const clickEvent = document.createEvent( "MouseEvents" ); clickEvent.initEvent( "click", true, false ); document.getElementById("that-element").dispatchEvent( clickEvent ); References : 1 : https://developer.mozilla.org/en-US/docs/Web/API/EventTarget... 2 : http://stack…

Here's code I wrote a while ago that did exactly what I specified and worked in production on all major browsers:

https://github.com/MediaCrush/MediaCrush/blob/master/scripts...

Here's the code in the jQuery library you linked to that does exactly this as well:

https://github.com/component/file-picker/blob/master/index.j...

Re: jQuery 3.0 Released

#44
post #30

Whenever a new version of jQuery (or Zepto) comes along, I wonder what would have happened if web development borrowed a page from other ecosystems and browser runtimes had subsumed the jQuery API, shipping it natively. It's a controversial notion, I'll grant, but what if the DOM APIs had been replaced by "native" jQuery support? Would we have been better off? Worse? Considering the intricacies of standards bodies an…

What version of jQuery exactly? They've made backwards incompatible changes; browsers can't do that.

Re: jQuery 3.0 Released

#45
post #26

Earlier quoted context omitted.

True. Although whenever I see a jQuery plugin like that I try to replace it with some combination of "components" [1]. There is a lot of progress in that area. There are stuff like : File picker [2], dropdown [3], tip [4] for tooltips and many more. 1 : https://github.com/component 2 : https://github.com/component/file-picker 3 : https://github.com/component/dropdown 4 : http://component.github.io/tip/

What is this "components"? I can't find anywhere that explains what it is. Is it just a random collection of javascript utilities?

CBP (component based programming) has been around (at least the idea has) since the 60s. It is the holy grail of some developers; being able to compose apps from a collection of components that work everywhere. I don't believe anyone has ever truly reached that goal. But surely it'll work this time because of JavaScript.

Re: jQuery 3.0 Released

#46
post #26

Earlier quoted context omitted.

True. Although whenever I see a jQuery plugin like that I try to replace it with some combination of "components" [1]. There is a lot of progress in that area. There are stuff like : File picker [2], dropdown [3], tip [4] for tooltips and many more. 1 : https://github.com/component 2 : https://github.com/component/file-picker 3 : https://github.com/component/dropdown 4 : http://component.github.io/tip/

What is this "components"? I can't find anywhere that explains what it is. Is it just a random collection of javascript utilities?

It was like browserify before browserify. It was a TJ project that was abandoned and replaced by Duo.

Re: jQuery 3.0 Released

#47
post #32
post #30

Whenever a new version of jQuery (or Zepto) comes along, I wonder what would have happened if web development borrowed a page from other ecosystems and browser runtimes had subsumed the jQuery API, shipping it natively. It's a controversial notion, I'll grant, but what if the DOM APIs had been replaced by "native" jQuery support? Would we have been better off? Worse? Considering the intricacies of standards bodies an…

Well it's 2016 and we still don't have nodeList.forEach() so it can't be much worse.

Array.from(document.getElementBy...).forEach ?

Re: jQuery 3.0 Released

#48
post #14

Earlier quoted context omitted.

Is that comparison supposed to show that jQuery is bad or what exactly? Because it's clear that jQuery is much more concise in every single case.

No. That site is giving helpful alternatives so that library authors can avoid having jquery as a dependency.

They are just recreating jQuery, no?

Re: jQuery 3.0 Released

#49
post #47
post #32

Earlier quoted context omitted.

Well it's 2016 and we still don't have nodeList.forEach() so it can't be much worse.

Array.from(document.getElementBy...).forEach ?

There are ways to do it for sure, but imagine if there was just One Obvious Way To Do It.

Re: jQuery 3.0 Released

#50
post #44
post #30

Whenever a new version of jQuery (or Zepto) comes along, I wonder what would have happened if web development borrowed a page from other ecosystems and browser runtimes had subsumed the jQuery API, shipping it natively. It's a controversial notion, I'll grant, but what if the DOM APIs had been replaced by "native" jQuery support? Would we have been better off? Worse? Considering the intricacies of standards bodies an…

What version of jQuery exactly? They've made backwards incompatible changes; browsers can't do that.

In theory, supporting backwards-incompatible changes should be well possible with versioning (with, e.g. the 's type attribute or a tag, or "use jquery14"; magic string or whatever) - everything should work as long as one can specify "I want libfoo API v2 here".
Post reply on HN