|
|
|
@ -3,28 +3,24 @@ module.exports = function niceNames () {
|
|
|
|
|
var ngScopeElts = document.getElementsByClassName('ng-scope');
|
|
|
|
|
ngScopeElts = Array.prototype.slice.call(ngScopeElts);
|
|
|
|
|
return ngScopeElts.
|
|
|
|
|
reduce(function (acc, elt) {
|
|
|
|
|
var $elt = angular.element(elt);
|
|
|
|
|
var scope = $elt.scope();
|
|
|
|
|
|
|
|
|
|
var name = {};
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
'ng-app',
|
|
|
|
|
'ng-controller',
|
|
|
|
|
'ng-repeat'
|
|
|
|
|
].
|
|
|
|
|
forEach(function (attr) {
|
|
|
|
|
var val = $elt.attr(attr),
|
|
|
|
|
className = $elt[0].className,
|
|
|
|
|
match,
|
|
|
|
|
lhs,
|
|
|
|
|
valueIdentifier,
|
|
|
|
|
keyIdentifier;
|
|
|
|
|
|
|
|
|
|
if (val) {
|
|
|
|
|
name[attr] = val;
|
|
|
|
|
if (attr === 'ng-repeat') {
|
|
|
|
|
reduce(accumulateElements, {});
|
|
|
|
|
|
|
|
|
|
function accumulateElements (acc, elt) {
|
|
|
|
|
acc[scope.$id] = nameElement(elt);
|
|
|
|
|
return acc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var interestingAttributes = {
|
|
|
|
|
'ng-app': function (value) {
|
|
|
|
|
// body...
|
|
|
|
|
},
|
|
|
|
|
'ng-controller': function (value) {
|
|
|
|
|
// body...
|
|
|
|
|
},
|
|
|
|
|
'ng-repeat': function (value) {
|
|
|
|
|
match = /(.+) in/.exec(val);
|
|
|
|
|
lhs = match[1];
|
|
|
|
|
|
|
|
|
@ -39,20 +35,41 @@ module.exports = function niceNames () {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else if (className.indexOf(attr) !== -1) {
|
|
|
|
|
match = (new RegExp(attr + ': ([a-zA-Z0-9]+);')).exec(className);
|
|
|
|
|
name[attr] = match[1];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function nameElement (element) {
|
|
|
|
|
var $elt = angular.element(elt),
|
|
|
|
|
scope = $elt.scope(),
|
|
|
|
|
name = {};
|
|
|
|
|
|
|
|
|
|
Object.keys(interestingAttributes).forEach(function (attributeName) {
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (Object.keys(name).length === 0) {
|
|
|
|
|
name.tag = $elt[0].tagName.toLowerCase();
|
|
|
|
|
name.classes = $elt[0].className.
|
|
|
|
|
return Object.keys(name).length > 0 ? name : boringName($elt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function boringName ($elt) {
|
|
|
|
|
return {
|
|
|
|
|
tag: $elt[0].tagName.toLowerCase(),
|
|
|
|
|
name: $elt[0].className.
|
|
|
|
|
replace(/(\W*ng-scope\W*)/, ' ').
|
|
|
|
|
split(' ').
|
|
|
|
|
filter(function (i) { return i; });
|
|
|
|
|
filter(function (i) { return i; })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseAttributeValue (attr) {
|
|
|
|
|
var val = $elt.attr(attr),
|
|
|
|
|
className;
|
|
|
|
|
|
|
|
|
|
if (!val && className.indexOf(attr) !== -1) {
|
|
|
|
|
|
|
|
|
|
className = $elt[0].className;
|
|
|
|
|
|
|
|
|
|
match = (new RegExp(attr + ': ([a-zA-Z0-9]+);')).exec(className);
|
|
|
|
|
val = match[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
acc[scope.$id] = name;
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
};
|
|
|
|
|