Version 0.50.0
Released on with 33 commits
This is a major update with some breaking changes. Expect a few more updates like this as we move closer to our 1.0 release in 2018.
General
- jQuery 3 is now supported in addition to jQuery 1.9+ and jQuery 2.
- ⚠️ Unpoly now uses native Promises instead of jQuery deferreds.
- You can now help improve Unpoly's documentation by clicking an Edit this page link on any unpoly.com subpage (like
[up-follow]).
Browser support
- ⚠️ To enable support for Internet Explorer 11 you need to install a Polyfill for
Promise. We recommend ES6-promise (2.4 KB gzipped). - Fix a bug where Unpoly would not boot on Safari 9 and 10 if the initial page was loaded with a
POSTmethod.
AJAX
- ⚠️ Unpoly now uses native XMLHttpRequest instead of
jQuery.ajax(). If you have been hacking into Unpoly's networking throughjQuery.ajaxPrefilter(), you must now use theup:proxy:loadevent. - 🧩
up.ajax()has been deprecated since its signature is incompatible with native promises. Please useup.request()instead, whose promise fulfills with anup.Responseobject. - 🧩 The
up:proxy:receivedevent has been renamed toup:proxy:loaded. - ⚠️ The
up:proxy:loadevent properties have changed. You can now access request properties through a key{ request }, e.g.event.request.url. - The
up:proxy:loadevent can now be prevented to prevent a request from being sent to the network. - The
up:proxy:loadevent now allows listeners to change request headers by manipulating theevent.request.headersobject. - A new event
up:proxy:fatalwill be emitted when an AJAX request encounters fatal error like a timeout or loss of network connectivity.
Links
- ⚠️ Links with unsafe HTTP methods like
POSTare no longer marked as.up-current, even if their[href]matches the current URL. - New experimental function
up.link.isSafe(). It returns whether the given link has a safe HTTP method likeGET.
Fragment updates
- When a selector was not found in the response, the error notification now offers a link to show the unexpected response.
- ⚠️ The event
up:fragment:destroycan no longer be prevented.
History
- Clicking a link with an
[up-restore-scroll]attribute will no longer crash if no previous scroll position for given URL is known (#25) - Fix a bug where going back in history would sometimes not call destructors (#24)
Forms
up.observe()no longer sends multiple callbacks when a previous callback was slow to respond.
Tooltips
- Fix a bug where tooltips would sometimes stay open when many tooltips are opened and closed concurrently.
Server protocol
- When the server signals a redirect with a
X-Up-Locationheader, sending aX-Up-Methodheader is now optional. If it is missing,GETis assumed. - Unpoly will often update a different selector in case the request fails. This second selector is now sent to the server as a
X-Up-Fail-Targetheader. - You can now configure how CSRF tokens are sent your server-side framework.
- ⚠️ CSRF tokens are no longer sent for cross-domain requests.
Animation
- ⚠️
up.motion.none()has been removed without replacement. Just passfalseor the string'none'to indicate a animation or transition which has no visual effects and completes instantly. - ⚠️
up.motion.finish()is now async. It returns a promise that fulfills when all animations are finished. - ⚠️
up.motion.finish()now also finishes animations in ancestors of the given element.
Modals
up.follow()will now open a modal if the given link has an[up-modal]attribute[up-modal]links can now have an[up-fail-target]attribute to indicate which selector to replace for an non-200 response- Fix a bug where preloading an up-modal link would create an invisible .up-modal container in the DOM.
Popups
up.follow()will now open a popup if the given link has[up-popup]attribute- up-popup links can now have an up-fail-target attribute to indicate which selector to replace for an non-200 response
- Fix a bug where preloading an up-popup link would create an invisible .up-popup container in the DOM.
- ⚠️
up.popup.attach()now throws an error if neither{ url }nor{ html }options are given.
Events
- ⚠️ When async functions emit an event and that event is prevented, the async function now rejects with an
Error. - ⚠️ When async functions are called wth
{ confirm: true }and the user denies confirmation, the async function now rejects with anError.
Utility functions
- ⚠️
up.util.setTimer()is now always async, even when called with a delay of0(zero). The function is now stable. - ⚠️
up.util.isHash()has been removed without replacement. In your code you can replaceup.util.isHash(x)withup.util.isObject(x) && !up.util.isFunction(x). - ⚠️
up.util.resolvedDeferred()has been removed without replacement. UsePromise.resolve()instead. - ⚠️
up.util.resolvedPromise()has been removed without replacement. UsePromise.resolve() instead. - ⚠️
up.util.rejectedPromise()has been removed without replacement. UsePromise.reject()instead. - ⚠️
up.util.unresolvableDeferred()has been removed without replacement. Usenew Promise(function() {})instead. - ⚠️
up.motion.when()has been removed without replacement. UsePromise.all()instead. up.util.isString()now also returns true forStringinstances (in addition to string literals)up.util.isNumber()now also returns true forNumberinstances (in addition to number literals)
Ruby on Rails bindings
- New method
up.fail_targetavailable in controllers, helpers and views. It returns the selector targeted for a failed response. - New method
up.fail_target?(target)available in controllers, helpers and views. It returns whether the given selector is targeted for a failed response. - New method
up.any_target?(target)available in controllers, helpers and views. It returns whether the given selector is targeted for a either a successful or failed response.