Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing tests without jQuery #4

Merged
merged 7 commits into from
Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/chaplin/views/layout.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = class Layout extends View
openLink: (event) =>
return if utils.modifierKeyPressed(event)

el = if Backbone.$ then event.currentTarget else event.delegateTarget
el = event.currentTarget
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to use currentTarget because delegateTarget didn't seems to have the same semantics in NativeView than its jQuery counterpart. Mind an issue in the NativeView repo?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all, thanks. I've been wondering about making the jump to use delegateTarget.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to revert this commit. It's the cause of 8 failling tests with NativeView.

isAnchor = el.nodeName is 'A'

# Get the href and perform checks on it.
Expand All @@ -115,7 +115,7 @@ module.exports = class Layout extends View
skipRouting = @settings.skipRouting
type = typeof skipRouting
return if type is 'function' and not skipRouting(href, el) or
type is 'string' and (if Backbone.$ then Backbone.$(el).is(skipRouting) else el.matches skipRouting)
type is 'string' and utils.matchesSelector.call el, skipRouting

# Handle external links.
external = isAnchor and @isExternalLink el
Expand Down Expand Up @@ -203,18 +203,13 @@ module.exports = class Layout extends View

# Apply the region selector.
instance.container = if region.selector is ''
if Backbone.$
region.instance.$el
else
region.instance.el
region.instance.el
else
if region.instance.noWrap
if Backbone.$
Backbone.$(region.instance.container).find region.selector
root = if region.instance.noWrap
region.instance.container
else
region.instance.container.querySelector region.selector
else
region.instance.$ region.selector
region.instance.el
root.querySelector region.selector

# Disposal
# --------
Expand Down
20 changes: 6 additions & 14 deletions test/spec/layout_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,8 @@ define [
instance2 = new Test2View {region: 'test2'}
instance3 = new Test2View {region: 'test0'}

if $
expect(instance2.container.attr('id')).to.be 'test2'
expect(instance3.container).to.be instance1.$el
else
expect(instance2.container.id).to.be 'test2'
expect(instance3.container).to.be instance1.el
expect(instance2.container.id).to.be 'test2'
expect(instance3.container).to.be instance1.el

instance1.dispose()
instance2.dispose()
Expand All @@ -375,10 +371,8 @@ define [
instance1 = new Test1View()
instance2 = new Test2View()
instance3 = new Test3View {region: 'test2'}
if $
expect(instance3.container.attr('id')).to.be 'test5'
else
expect(instance3.container.id).to.be 'test5'

expect(instance3.container.id).to.be 'test5'

instance1.dispose()
instance2.dispose()
Expand Down Expand Up @@ -407,10 +401,8 @@ define [
instance2 = new Test2View()
instance2.stale = true
instance3 = new Test3View {region: 'test2'}
if $
expect(instance3.container.attr('id')).to.be 'test2'
else
expect(instance3.container.id).to.be 'test2'

expect(instance3.container.id).to.be 'test2'

instance1.dispose()
instance2.dispose()
Expand Down