Revision code

Changes Version 0.50.0
Released on December 06, 2017 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 a[up-target]).

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 POST method.

AJAX

  • Unpoly now uses native XMLHttpRequest instead of jQuery.ajax(). If you have been hacking into Unpoly's networking through jQuery.ajaxPrefilter(), you must now use the up:proxy:load event.
  • up.ajax() has been deprecated since its signature is incompatible with native promises. Please use up.request() instead, whose promise fulfills with an up.Response object.
  • The up:proxy:received event has been renamed to up:proxy:loaded.
  • The up:proxy:load event properties have changed. You can now access request properties through a key { request }, e.g. event.request.url.
  • The up:proxy:load event can now be prevented to prevent a request from being sent to the network.
  • The up:proxy:load event now allows listeners to change request headers by manipulating the event.request.headers object.
  • A new event up:proxy:fatal will be emitted when an AJAX request encounters fatal error like a timeout or loss of network connectivity.
  • Links with unsafe HTTP methods like POST are 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 like GET.

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:destroy can 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

Animation

  • up.motion.none() has been removed without replacement. Just pass false or 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
  • a[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 an Error.

Utility functions

  • up.util.setTimer() is now always async, even when called with a delay of 0 (zero). The function is now stable.
  • up.util.isHash() has been removed without replacement. In your code you can replace up.util.isHash(x) with up.util.isObject(x) && !up.util.isFunction(x).
  • up.util.resolvedDeferred() has been removed without replacement. Use Promise.resolve() instead.
  • up.util.resolvedPromise() has been removed without replacement. Use Promise.resolve() instead.
  • up.util.rejectedPromise() has been removed without replacement. Use Promise.reject() instead.
  • up.util.unresolvableDeferred() has been removed without replacement. Use new Promise(function() {}) instead.
  • up.motion.when() has been removed without replacement. Use Promise.all() instead.
  • up.util.isString() now also returns true for String instances (in addition to string literals)
  • up.util.isNumber() now also returns true for Number instances (in addition to number literals)

Ruby on Rails bindings

  • New method up.fail_target available 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.

Upgrading

If you're upgrading from an older Unpoly version you should load unpoly-migrate.js to polyfill deprecated APIs. Changes handled by unpoly-migrate.js are not considered breaking changes.

See our upgrading guide for details.