unpoly-rails 0.50.1 → 0.50.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of unpoly-rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/dist/unpoly.js +85 -75
- data/dist/unpoly.min.js +4 -4
- data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +3 -1
- data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +2 -5
- data/lib/assets/javascripts/unpoly/dom.coffee +1 -1
- data/lib/assets/javascripts/unpoly/form.coffee +9 -1
- data/lib/assets/javascripts/unpoly/layout.coffee +48 -46
- data/lib/assets/javascripts/unpoly/link.coffee +5 -4
- data/lib/assets/javascripts/unpoly/proxy.coffee +5 -5
- data/lib/assets/javascripts/unpoly/syntax.coffee +8 -4
- data/lib/unpoly/rails/version.rb +1 -1
- data/package.json +1 -1
- data/spec_app/Gemfile.lock +1 -1
- data/spec_app/spec/javascripts/helpers/trigger.js.coffee +1 -1
- data/spec_app/spec/javascripts/up/layout_spec.js.coffee +6 -0
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +73 -1
- metadata +2 -2
@@ -261,10 +261,11 @@ up.link = (($) ->
|
|
261
261
|
unless isFollowable($link)
|
262
262
|
$link.attr('up-follow', '')
|
263
263
|
|
264
|
-
|
264
|
+
shouldProcessEvent = (event, $link) ->
|
265
265
|
$target = $(event.target)
|
266
|
-
$
|
267
|
-
$
|
266
|
+
$targetedChildLink = $target.closest('a, [up-href]').not($link)
|
267
|
+
$targetedInput = up.form.fieldSelector().seekUp($target)
|
268
|
+
$targetedChildLink.length == 0 && $targetedInput.length == 0 && u.isUnmodifiedMouseEvent(event)
|
268
269
|
|
269
270
|
###*
|
270
271
|
Returns whether the given link has a [safe](https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.1)
|
@@ -553,7 +554,7 @@ up.link = (($) ->
|
|
553
554
|
makeFollowable: makeFollowable
|
554
555
|
isSafe: isSafe
|
555
556
|
isFollowable: isFollowable
|
556
|
-
|
557
|
+
shouldProcessEvent: shouldProcessEvent
|
557
558
|
followMethod: followMethod
|
558
559
|
addFollowVariant: addFollowVariant
|
559
560
|
followVariantForLink: followVariantForLink
|
@@ -159,7 +159,7 @@ up.proxy = (($) ->
|
|
159
159
|
|
160
160
|
up.request('/search', data: { query: 'sunshine' }).then(function(response) {
|
161
161
|
console.log('The response text is %o', response.text);
|
162
|
-
}).
|
162
|
+
}).catch(function() {
|
163
163
|
console.error('The request failed');
|
164
164
|
});
|
165
165
|
|
@@ -266,7 +266,7 @@ up.proxy = (($) ->
|
|
266
266
|
|
267
267
|
up.request('/search', data: { query: 'sunshine' }).then(function(text) {
|
268
268
|
console.log('The response text is %o', text);
|
269
|
-
}).
|
269
|
+
}).catch(function() {
|
270
270
|
console.error('The request failed');
|
271
271
|
});
|
272
272
|
|
@@ -631,11 +631,11 @@ up.proxy = (($) ->
|
|
631
631
|
but will also make the interaction feel less instant.
|
632
632
|
@stable
|
633
633
|
###
|
634
|
-
up.on 'mouseover mousedown touchstart', 'a[up-preload], [up-href][up-preload]', (event, $
|
634
|
+
up.on 'mouseover mousedown touchstart', 'a[up-preload], [up-href][up-preload]', (event, $link) ->
|
635
635
|
# Don't do anything if we are hovering over the child of a link.
|
636
636
|
# The actual link will receive the event and bubble in a second.
|
637
|
-
if
|
638
|
-
checkPreload($
|
637
|
+
if up.link.shouldProcessEvent(event, $link) && up.link.isSafe($link)
|
638
|
+
checkPreload($link)
|
639
639
|
|
640
640
|
up.on 'up:framework:reset', reset
|
641
641
|
|
@@ -345,10 +345,14 @@ up.syntax = (($) ->
|
|
345
345
|
$matches = u.selectInSubtree($fragment, compiler.selector)
|
346
346
|
|
347
347
|
# Exclude all elements that are descendants of the subtrees we want to keep.
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
348
|
+
# We only do this if `options.skip` was given, since the exclusion
|
349
|
+
# process below is very expensive (we had a case where compiling 100 slements
|
350
|
+
# took 1.5s because of this).
|
351
|
+
if $skipSubtrees.length
|
352
|
+
$matches = $matches.filter ->
|
353
|
+
$match = $(this)
|
354
|
+
u.all $skipSubtrees, (skipSubtree) ->
|
355
|
+
$match.closest(skipSubtree).length == 0
|
352
356
|
|
353
357
|
if $matches.length
|
354
358
|
up.log.group ("Compiling '%s' on %d element(s)" unless compiler.isSystem), compiler.selector, $matches.length, ->
|
data/lib/unpoly/rails/version.rb
CHANGED
data/package.json
CHANGED
data/spec_app/Gemfile.lock
CHANGED
@@ -207,6 +207,12 @@ describe 'up.layout', ->
|
|
207
207
|
# [F] 0 ............ 99
|
208
208
|
expect($(document).scrollTop()).toBe(@clientHeight + 50)
|
209
209
|
|
210
|
+
it 'does not crash when called with a CSS selector (bugfix)', (done) ->
|
211
|
+
promise = up.reveal('.container')
|
212
|
+
promiseState(promise).then (result) ->
|
213
|
+
expect(result.state).toEqual('fulfilled')
|
214
|
+
done()
|
215
|
+
|
210
216
|
describe 'with { top: true } option', ->
|
211
217
|
|
212
218
|
it 'scrolls the viewport to the first row of the element, even if that element is already fully revealed', asyncSpec (next) ->
|
@@ -368,7 +368,7 @@ describe 'up.link', ->
|
|
368
368
|
|
369
369
|
describeFallback 'canPushState', ->
|
370
370
|
|
371
|
-
it '
|
371
|
+
it 'navigates to the given link without JavaScript', asyncSpec (next) ->
|
372
372
|
$link = affix('a[href="/path"]')
|
373
373
|
spyOn(up.browser, 'navigate')
|
374
374
|
up.follow($link)
|
@@ -384,6 +384,57 @@ describe 'up.link', ->
|
|
384
384
|
next =>
|
385
385
|
expect(up.browser.navigate).toHaveBeenCalledWith('/path', { method: 'PUT' })
|
386
386
|
|
387
|
+
describe 'up.link.shouldProcessEvent', ->
|
388
|
+
|
389
|
+
buildEvent = ($element, attrs) ->
|
390
|
+
event = Trigger.createMouseEvent('mousedown', attrs)
|
391
|
+
event = $.event.fix(event) # convert native event to jQuery event
|
392
|
+
event.target = u.unJQuery($element)
|
393
|
+
event
|
394
|
+
|
395
|
+
it "returns true when the given event's target is the given link itself", ->
|
396
|
+
$link = affix('a[href="/foo"]')
|
397
|
+
event = buildEvent($link)
|
398
|
+
expect(up.link.shouldProcessEvent(event, $link)).toBe(true)
|
399
|
+
|
400
|
+
it "returns true when the given event's target is a non-link child of the given link", ->
|
401
|
+
$link = affix('a[href="/foo"]')
|
402
|
+
$span = $link.affix('span')
|
403
|
+
event = buildEvent($span)
|
404
|
+
expect(up.link.shouldProcessEvent(event, $link)).toBe(true)
|
405
|
+
|
406
|
+
it "returns false when the given event's target is a child link of the given link (think [up-expand])", ->
|
407
|
+
$link = affix('div[up-href="/foo"]')
|
408
|
+
$childLink = $link.affix('a[href="/bar"]')
|
409
|
+
event = buildEvent($childLink)
|
410
|
+
expect(up.link.shouldProcessEvent(event, $link)).toBe(false)
|
411
|
+
|
412
|
+
it "returns false when the given event's target is a child input of the given link (think [up-expand])", ->
|
413
|
+
$link = affix('div[up-href="/foo"]')
|
414
|
+
$childInput = $link.affix('input[type="text"]')
|
415
|
+
event = buildEvent($childInput)
|
416
|
+
expect(up.link.shouldProcessEvent(event, $link)).toBe(false)
|
417
|
+
|
418
|
+
it 'returns false if the right mouse button is used', ->
|
419
|
+
$link = affix('a[href="/foo"]')
|
420
|
+
event = buildEvent($link, button: 2)
|
421
|
+
expect(up.link.shouldProcessEvent(event, $link)).toBe(false)
|
422
|
+
|
423
|
+
it 'returns false if shift is pressed during the click', ->
|
424
|
+
$link = affix('a[href="/foo"]')
|
425
|
+
event = buildEvent($link, shiftKey: 2)
|
426
|
+
expect(up.link.shouldProcessEvent(event, $link)).toBe(false)
|
427
|
+
|
428
|
+
it 'returns false if ctrl is pressed during the click', ->
|
429
|
+
$link = affix('a[href="/foo"]')
|
430
|
+
event = buildEvent($link, ctrlKey: 2)
|
431
|
+
expect(up.link.shouldProcessEvent(event, $link)).toBe(false)
|
432
|
+
|
433
|
+
it 'returns false if meta is pressed during the click', ->
|
434
|
+
$link = affix('a[href="/foo"]')
|
435
|
+
event = buildEvent($link, metaKey: 2)
|
436
|
+
expect(up.link.shouldProcessEvent(event, $link)).toBe(false)
|
437
|
+
|
387
438
|
describe 'up.link.makeFollowable', ->
|
388
439
|
|
389
440
|
it "adds [up-follow] to a link that wouldn't otherwise be handled by Unpoly", ->
|
@@ -824,6 +875,27 @@ describe 'up.link', ->
|
|
824
875
|
next =>
|
825
876
|
expect(up.replace).toHaveBeenCalled()
|
826
877
|
|
878
|
+
it 'does nothing when the user clicks another link in the expanded area', asyncSpec (next) ->
|
879
|
+
$area = affix('div[up-expand]')
|
880
|
+
$expandedLink = $area.affix('a[href="/expanded-path"][up-follow]')
|
881
|
+
$otherLink = $area.affix('a[href="/other-path"][up-follow]')
|
882
|
+
up.hello($area)
|
883
|
+
followSpy = up.link.knife.mock('defaultFollow').and.returnValue(Promise.resolve())
|
884
|
+
Trigger.clickSequence($otherLink)
|
885
|
+
next =>
|
886
|
+
expect(followSpy.calls.count()).toEqual(1)
|
887
|
+
expect(followSpy.calls.mostRecent().args[0]).toEqual($otherLink)
|
888
|
+
|
889
|
+
it 'does nothing when the user clicks on an input in the expanded area', asyncSpec (next) ->
|
890
|
+
$area = affix('div[up-expand]')
|
891
|
+
$expandedLink = $area.affix('a[href="/expanded-path"][up-follow]')
|
892
|
+
$input = $area.affix('input[type=text]')
|
893
|
+
up.hello($area)
|
894
|
+
followSpy = up.link.knife.mock('defaultFollow').and.returnValue(Promise.resolve())
|
895
|
+
Trigger.clickSequence($input)
|
896
|
+
next =>
|
897
|
+
expect(followSpy).not.toHaveBeenCalled()
|
898
|
+
|
827
899
|
it 'does not trigger multiple replaces when the user clicks on the expanded area of an [up-instant] link (bugfix)', asyncSpec (next) ->
|
828
900
|
$area = affix('div[up-expand] a[href="/path"][up-follow][up-instant]')
|
829
901
|
up.hello($area)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unpoly-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.50.
|
4
|
+
version: 0.50.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|