Browse Source

Merge pull request #890 from KorsaR-ZN/bugfix-1

Added support attribute "data-ng-repeat"
pull/612/merge
Lebedev Konstantin 9 years ago committed by GitHub
parent
commit
cb060d8547
  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 === 1) &&
(node.attributes['ng-repeat'])
);
return node.nodeType === Node.ELEMENT_NODE && getNgRepeatExpression(node);
})[0];
if (!ngRepeat) {
return;
}
var expression = ngRepeat.attributes['ng-repeat'].nodeValue;
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