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

Loading…
Cancel
Save