diff --git a/bower.json b/bower.json index b2ba943b..4e6648b5 100644 --- a/bower.json +++ b/bower.json @@ -11,7 +11,7 @@ "sinon": "http://sinonjs.org/releases/sinon-1.7.1.js", "requirejs": "~2.1.8", "davy": "~0.0.4", - "Backbone.NativeView": "0.3.1", + "backbone.nativeview": "0.3.1", "exoskeleton": "~0.7.0" }, "exportsOverride": { diff --git a/package.json b/package.json index 54ff525a..9e048130 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "grunt-istanbul": "0.2.x", "grunt-urequire": "git://github.com/concordusapps/grunt-urequire", "grunt-coffeelint": "0.0.x", - "grunt-mocha": "0.2.x", + "grunt-mocha": "0.4.11", "grunt-transbrute": "~0.2.0", "prompt": "0.2.x", "phantomjs": "1.9.x" diff --git a/src/chaplin/views/collection_view.coffee b/src/chaplin/views/collection_view.coffee index 6a84700f..96ffc29d 100644 --- a/src/chaplin/views/collection_view.coffee +++ b/src/chaplin/views/collection_view.coffee @@ -5,14 +5,9 @@ Backbone = require 'backbone' View = require 'chaplin/views/view' utils = require 'chaplin/lib/utils' -filterChildren = (nodeList, selector) -> - return nodeList unless selector - for node in nodeList when Backbone.utils.matchesSelector node, selector - node - toggleElement = (elem, visible) -> if Backbone.$ - $(elem).toggle visible + Backbone.$(elem).toggle visible else elem.style.display = (if visible then '' else 'none') @@ -24,7 +19,7 @@ startAnimation = (elem, useCssAnimation, cls) -> endAnimation = (elem, duration) -> if Backbone.$ - elem.animate {opacity: 1}, duration + Backbone.$(elem).animate {opacity: 1}, duration else elem.style.transition = "opacity #{(duration / 1000)}s" elem.opacity = 1 @@ -35,7 +30,7 @@ insertView = (list, viewEl, position, length, itemSelector) -> if insertInMiddle or itemSelector # Get the children which originate from item views. - children = filterChildren list.children, itemSelector + children = list.querySelectorAll(itemSelector) childrenLength = children.length # Check if it needs to be inserted. diff --git a/test/spec/collection_view_spec.coffee b/test/spec/collection_view_spec.coffee index 87fa7484..f534f736 100644 --- a/test/spec/collection_view_spec.coffee +++ b/test/spec/collection_view_spec.coffee @@ -412,51 +412,36 @@ define [ it 'should animate the opacity of new items', -> return unless jQuery - $css = sinon.stub jQuery.prototype, 'css', -> this $animate = sinon.stub jQuery.prototype, 'animate', -> this createCollection() collectionView = new AnimatingCollectionView {collection} - expect($css.callCount).to.be collection.length - expect($css).was.calledWith 'opacity', 0 - expect($animate.callCount).to.be collection.length args = $animate.firstCall.args expect(args[0]).to.eql opacity: 1 expect(args[1]).to.be collectionView.animationDuration - expect($css.calledBefore($animate)).to.be true - - addThree() - expect($css.callCount).to.be collection.length - - $css.restore() $animate.restore() it 'should not animate if animationDuration is 0', -> return unless jQuery - $css = sinon.spy jQuery.prototype, 'css' $animate = sinon.spy jQuery.prototype, 'animate' createCollection() collectionView = new TestCollectionView {collection} - expect($css).was.notCalled() expect($animate).was.notCalled() addThree() - expect($css).was.notCalled() expect($animate).was.notCalled() - $css.restore() $animate.restore() it 'should not animate when re-inserting', -> return unless jQuery - $css = sinon.stub jQuery.prototype, 'css', -> this $animate = sinon.stub jQuery.prototype, 'animate', -> this model1 = new Model id: 1 @@ -466,15 +451,12 @@ define [ createCollection [model1, model2] collectionView = new AnimatingCollectionView {collection} - expect($css).was.calledTwice() expect($animate).was.calledTwice() collection.reset [model1, model2, model3] - expect($css.callCount).to.be collection.length expect($animate.callCount).to.be collection.length - $css.restore() $animate.restore() it 'should animate with CSS classes', (done) ->