Skip to content
This repository has been archived by the owner on Dec 30, 2018. It is now read-only.

Commit

Permalink
fix(app): enforce new scope for each brick
Browse files Browse the repository at this point in the history
  • Loading branch information
passy committed Aug 4, 2013
1 parent 65a98af commit ad854df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/angular-masonry.js
Expand Up @@ -23,7 +23,7 @@
if (!found) {
this.scheduleMasonry.apply(null, arguments);
}
}
};

// Make sure it's only executed once within a reasonable time-frame in
// case multiple elements are removed or added at once.
Expand All @@ -43,7 +43,7 @@
});
schedule = [];
}, 30);
}
};

function defaultLoaded($element) {
$element.addClass('loaded');
Expand Down Expand Up @@ -116,6 +116,7 @@
return {
restrict: 'AC',
require: '^masonry',
scope: true,
link: function postLink(scope, element, attrs, ctrl) {
var id = scope.$id;

Expand Down
21 changes: 21 additions & 0 deletions test/spec/directive.coffee
Expand Up @@ -114,3 +114,24 @@ describe 'angular-masonry', ->
expect(@appendBrick).toHaveBeenCalledThrice()
expect(@removeBrick).toHaveBeenCalledOnce()
)

describe 'masonry-brick internals', =>
beforeEach ->
$.fn.imagesLoaded = (cb) -> cb()

afterEach ->
delete $.fn.imagesLoaded

it 'should append three elements to the controller', inject(($compile) =>
element = angular.element '''
<masonry>
<div class="masonry-brick"></div>
<div class="masonry-brick"></div>
<div class="masonry-brick"></div>
</masonry>
'''
element = $compile(element)(@scope)
@scope.$digest()
# 2 is resize and one layout, 3 for the elements
expect($.fn.masonry.callCount).toBe(2 + 3)
)

0 comments on commit ad854df

Please sign in to comment.