lib/assets/javascripts/up/flow.js.coffee in upjs-rails-0.2.2 vs lib/assets/javascripts/up/flow.js.coffee in upjs-rails-0.3.0

- old
+ new

@@ -93,10 +93,16 @@ implant = (selector, html, options) -> options = u.options(options, historyMethod: 'push' ) + + if options.history == 'false' + options.history = null + + options.source = u.option(options.source, options.history) + # jQuery cannot construct transient elements that contain <html> or <body> tags, # so we're using the native browser API to grep through the HTML htmlElement = u.createElementFromHtml(html) # TODO: extract title from HTTP header @@ -113,29 +119,29 @@ swapElements $old, $new, step.pseudoClass, step.transition, options else u.error("Could not find selector (#{step.selector}) in response (#{html})") elementsInserted = ($new, options) -> - $new.each -> - $element = $(this) - options.insert?($element) - if options.history - document.title = options.title if options.title - up.history[options.historyMethod](options.history) - # Remember where the element came from so we can - # offer reload functionality. - setSource($element, u.presence(options.source) || options.history) - autofocus($element) - # The fragment should be readiet before the transition, - # so transitions see .up-current classes - up.ready($element) + options.insert?($new) + if options.history + document.title = options.title if options.title + up.history[options.historyMethod](options.history) + # Remember where the element came from so we can + # offer reload functionality. + setSource($new, options.source) + autofocus($new) + # The fragment should be readiet before animating, + # so transitions see .up-current classes + up.ready($new) swapElements = ($old, $new, pseudoClass, transition, options) -> transition ||= 'none' if pseudoClass insertionMethod = if pseudoClass == 'before' then 'prepend' else 'append' # Keep a reference to the children append/prepend because - # we need to compile them further down + # we need to compile them further down. Note that since we're + # prepending/appending instead of rpelacing, `$new` will not + # actually be inserted into the DOM, only its children. $addedChildren = $new.children() # Insert contents() instead of $children since contents() # also includes text nodes. $old[insertionMethod]($new.contents()) u.copyAttributes($new, $old)