Skip to content

Commit

Permalink
Make Elemental.load() accept HTML with multiple root nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Finnie and Evan Goodberry committed Nov 1, 2013
1 parent 76c9170 commit f2b47cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 7 additions & 0 deletions spec/elemental_spec.js
Expand Up @@ -38,6 +38,13 @@ describe("Elemental", function(){
expect(bar).toHaveBeenCalled();
});

it("should load behaviors on all top-level container elements", function() {
bar = jasmine.createSpy('bar');
var container = "<div data-behavior='bar'> </div> <div data-behavior='bar'> </div>";
Elemental.load(container);
expect(bar.callCount).toEqual(2);
});

describe("when the container is some specific DOM", function() {
it("should load a behavior nested deeply beneath the container element", function() {
baz = jasmine.createSpy('baz');
Expand Down
7 changes: 1 addition & 6 deletions src/elemental.js
Expand Up @@ -29,12 +29,7 @@
};

ns.load = function(container) {
var $selector;
$selector = $('[data-behavior]', container);

if ($(container).data('behavior')) {
$selector = $selector.add(container);
}
var $selector = $('[data-behavior]', container).add($(container).filter('[data-behavior]'));

$selector.each(function(index, element) {
var $element = $(element);
Expand Down

0 comments on commit f2b47cf

Please sign in to comment.