lib/assets/javascripts/unpoly/classes/extract_cascade.coffee in unpoly-rails-0.57.0 vs lib/assets/javascripts/unpoly/classes/extract_cascade.coffee in unpoly-rails-0.60.0

- old
+ new

@@ -1,28 +1,28 @@ u = up.util class up.ExtractCascade - constructor: (selector, options) -> + constructor: (selectorOrElement, options) -> @options = u.options(options, humanizedTarget: 'selector', layer: 'auto') - @options.transition = u.option(@options.transition, @options.animation) - @options.hungry = u.option(@options.hungry, true) + @options.transition ?= @options.animation + @options.hungry ?= true - @candidates = @buildCandidates(selector) + @candidates = @buildCandidates(selectorOrElement) @plans = u.map @candidates, (candidate, i) => planOptions = u.copy(@options) if i > 0 # If we're using a fallback (any candidate that's not the first), # the original transition might no longer be appropriate. - planOptions.transition = u.option(up.dom.config.fallbackTransition, @options.transition) + planOptions.transition = up.fragment.config.fallbackTransition ? @options.transition new up.ExtractPlan(candidate, planOptions) buildCandidates: (selector) -> - candidates = [selector, @options.fallback, up.dom.config.fallbacks] + candidates = [selector, @options.fallback, up.fragment.config.fallbacks] candidates = u.flatten(candidates) # Remove undefined, null and false from the list - candidates = u.select(candidates, u.isTruthy) + candidates = u.filter(candidates, u.isTruthy) candidates = u.uniq(candidates) if @options.fallback == false || @options.provideTarget # Use the first defined candidate, but not `selector` since that # might be an undefined options.failTarget @@ -37,10 +37,10 @@ matchingPlan: => @detectPlan('matchExists') detectPlan: (checker) => - u.detect @plans, (plan) -> plan[checker]() + u.find @plans, (plan) -> plan[checker]() bestPreflightSelector: => if @options.provideTarget # We know that the target will be created right before swapping, # so just assume the first plan will work.