Browse Source

code improvement

pull/890/head
Stanislav Kiryukhin 9 years ago
parent
commit
995519ac09
  1. 13
      ng-sortable.js

13
ng-sortable.js

@ -37,6 +37,10 @@
var removed, var removed,
nextSibling; nextSibling;
function getNgRepeatExpression(node) {
return node.getAttribute('ng-repeat') || node.getAttribute('data-ng-repeat') || node.getAttribute('x-ng-repeat');
}
// Export // Export
return { return {
restrict: 'AC', restrict: 'AC',
@ -45,18 +49,15 @@
compile: function ($element, $attr) { compile: function ($element, $attr) {
var ngRepeat = [].filter.call($element[0].childNodes, function (node) { var ngRepeat = [].filter.call($element[0].childNodes, function (node) {
return ( return node.nodeType === Node.ELEMENT_NODE && getNgRepeatExpression(node);
node.nodeType === Node.ELEMENT_NODE &&
angular.element(node).data('ngRepeat')
);
})[0]; })[0];
if (!ngRepeat) { if (!ngRepeat) {
return; return;
} }
var expression = angular.element(ngRepeat).data('ngRepeat'); var match = getNgRepeatExpression(ngRepeat)
var match = expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/); .match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
if (!match) { if (!match) {
return; return;

Loading…
Cancel
Save