Revision code

Changes Version 0.33.0
Released on January 28, 2017 with 26 commits

Compatible changes

  • When a fragment updates cannot find the requested element, you can now define a fallback selector to use instead.

    A { fallback } option has been added to all JavaScript functions that update fragments, like up.replace().

    Also an [up-fallback] attribute has been added to all CSS selectors that update fragments, like for a[up-target].

    You can also define fallbacks globally using the up.dom.config property.

  • Unpoly no longer crashes when a request fails due to a timeout or network problem. In such cases, async functions (like up.replace()) will leave the page unchanged and reject the returned promise.
  • Functions that make a request (like up.replace() or like up.ajax()) now accept a new option { timeout }.
  • Modals no longer create an .up-modal element when the server returns a non-200 status and the { failTarget } is replaced instead
  • Popups no longer create an .up-popup element when the server returns a non-200 status and the { failTarget } is replaced instead
  • Improve performance when updating fragments without transitions
  • When updating the <body> element with a transition, that transition is now silently ignored instead of throwing an error.
  • up.util.resolvedPromise() now accepts arguments which will become the resolution values.
  • up.util.resolvedDeferred() now accepts arguments which will become the resolution values.
  • New utility method up.util.rejectedPromise().
  • up.first() has new option { origin }. You can use it provide a second element or selector that can be referenced as & in the first selector:

    $input = $('input.email');
    up.first('.field:has(&)', $input); // returns the .field containing $input
    
  • Fix a bug where the document title wasn't restored when the user uses the back button
  • When revealing a page fragment, Unpoly will include the element's top and bottom margin in the area that should be revealed.

Breaking changes

  • up.replace() now returns a rejected promise if the server returns a non-200 status code.
  • up.util.merge() has been replaced with up.util.assign(), which no longer makes exceptions for null and undefined property values. This behaves like Object.assign.
  • The up.flow module has been renamed to up.dom.
  • The up.navigation module has been renamed to up.feedback.
  • Functions that measure position, dimensions or margin now return floats instead of rounded integers.

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.