mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-15 12:09:02 +08:00
refactor: rename getBlockElements to more correct getBlockNodes
This commit is contained in:
@@ -85,7 +85,7 @@
|
||||
"assertArgFn": false,
|
||||
"assertNotHasOwnProperty": false,
|
||||
"getter": false,
|
||||
"getBlockElements": false,
|
||||
"getBlockNodes": false,
|
||||
"VALIDITY_STATE_PROPERTY": false,
|
||||
|
||||
"skipDestroyOnNextJQueryCleanData": true,
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
assertArgFn: true,
|
||||
assertNotHasOwnProperty: true,
|
||||
getter: true,
|
||||
getBlockElements: true,
|
||||
getBlockNodes: true,
|
||||
hasOwnProperty: true,
|
||||
*/
|
||||
|
||||
@@ -1564,23 +1564,20 @@ function getter(obj, path, bindFnToScope) {
|
||||
/**
|
||||
* Return the DOM siblings between the first and last node in the given array.
|
||||
* @param {Array} array like object
|
||||
* @returns {DOMElement} object containing the elements
|
||||
* @returns {jqLite} jqLite collection containing the nodes
|
||||
*/
|
||||
function getBlockElements(nodes) {
|
||||
var startNode = nodes[0],
|
||||
endNode = nodes[nodes.length - 1];
|
||||
if (startNode === endNode) {
|
||||
return jqLite(startNode);
|
||||
}
|
||||
|
||||
var element = startNode;
|
||||
var elements = [element];
|
||||
function getBlockNodes(nodes) {
|
||||
// TODO(perf): just check if all items in `nodes` are siblings and if they are return the original
|
||||
// collection, otherwise update the original collection.
|
||||
var node = nodes[0];
|
||||
var endNode = nodes[nodes.length - 1];
|
||||
var blockNodes = [node];
|
||||
|
||||
do {
|
||||
element = element.nextSibling;
|
||||
if (!element) break;
|
||||
elements.push(element);
|
||||
} while (element !== endNode);
|
||||
node = node.nextSibling;
|
||||
if (!node) break;
|
||||
blockNodes.push(node);
|
||||
} while (node !== endNode);
|
||||
|
||||
return jqLite(elements);
|
||||
return jqLite(blockNodes);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ var ngIfDirective = ['$animate', function($animate) {
|
||||
childScope = null;
|
||||
}
|
||||
if(block) {
|
||||
previousElements = getBlockElements(block.clone);
|
||||
previousElements = getBlockNodes(block.clone);
|
||||
$animate.leave(previousElements, function() {
|
||||
previousElements = null;
|
||||
});
|
||||
|
||||
@@ -350,7 +350,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
|
||||
// lastBlockMap is our own object so we don't need to use special hasOwnPropertyFn
|
||||
if (lastBlockMap.hasOwnProperty(blockKey)) {
|
||||
block = lastBlockMap[blockKey];
|
||||
elementsToRemove = getBlockElements(block.clone);
|
||||
elementsToRemove = getBlockNodes(block.clone);
|
||||
$animate.leave(elementsToRemove);
|
||||
forEach(elementsToRemove, function(element) { element[NG_REMOVED] = true; });
|
||||
block.scope.$destroy();
|
||||
@@ -374,7 +374,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
|
||||
|
||||
if (getBlockStart(block) != nextNode) {
|
||||
// existing item which got moved
|
||||
$animate.move(getBlockElements(block.clone), null, jqLite(previousNode));
|
||||
$animate.move(getBlockNodes(block.clone), null, jqLite(previousNode));
|
||||
}
|
||||
previousNode = getBlockEnd(block);
|
||||
updateScope(block.scope, index);
|
||||
|
||||
@@ -152,7 +152,7 @@ var ngSwitchDirective = ['$animate', function($animate) {
|
||||
previousElements.length = 0;
|
||||
|
||||
for (i = 0, ii = selectedScopes.length; i < ii; ++i) {
|
||||
var selected = getBlockElements(selectedElements[i].clone);
|
||||
var selected = getBlockNodes(selectedElements[i].clone);
|
||||
selectedScopes[i].$destroy();
|
||||
previousElements[i] = selected;
|
||||
$animate.leave(selected, function() {
|
||||
|
||||
Reference in New Issue
Block a user