Skip to content

Commit

Permalink
chore: move getBlockElements to Angular.js
Browse files Browse the repository at this point in the history
  • Loading branch information
btford committed Oct 30, 2013
1 parent e19067c commit 6578bd0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"assertArgFn": false,
"assertNotHasOwnProperty": false,
"getter": false,
"getBlockElements": false,

/* AngularPublic.js */
"version": false,
Expand Down
25 changes: 24 additions & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
-assertArg,
-assertArgFn,
-assertNotHasOwnProperty,
-getter
-getter,
-getBlockElements
*/

Expand Down Expand Up @@ -1318,3 +1319,25 @@ function getter(obj, path, bindFnToScope) {
}
return obj;
}

/**
* Return the siblings between `startNode` and `endNode`, inclusive
* @param {Object} object with `startNode` and `endNode` properties
* @returns jQlite object containing the elements
*/
function getBlockElements(block) {
if (block.startNode === block.endNode) {
return jqLite(block.startNode);
}

var element = block.startNode;
var elements = [element];

do {
element = element.nextSibling;
if (!element) break;
elements.push(element);
} while (element !== block.endNode);

return jqLite(elements);
}
18 changes: 0 additions & 18 deletions src/ng/directive/ngIf.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,4 @@ var ngIfDirective = ['$animate', function($animate) {
};
}
};

// TODO(bford): this helper was copypasta'd from ngRepeat
function getBlockElements(block) {
if (block.startNode === block.endNode) {
return jqLite(block.startNode);
}

var element = block.startNode;
var elements = [element];

do {
element = element.nextSibling;
if (!element) break;
elements.push(element);
} while (element !== block.endNode);

return jqLite(elements);
}
}];
17 changes: 0 additions & 17 deletions src/ng/directive/ngRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,22 +393,5 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
};
}
};

function getBlockElements(block) {
if (block.startNode === block.endNode) {
return jqLite(block.startNode);
}

var element = block.startNode;
var elements = [element];

do {
element = element.nextSibling;
if (!element) break;
elements.push(element);
} while (element !== block.endNode);

return jqLite(elements);
}
}];

0 comments on commit 6578bd0

Please sign in to comment.