From cd2a9e495d31477c53a7e2fb0caf086accad81e5 Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Tue, 29 Apr 2014 15:22:22 -0700 Subject: [PATCH] fix: niceNames --- app/content-scripts/lib/niceNames.js | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/content-scripts/lib/niceNames.js b/app/content-scripts/lib/niceNames.js index c03056e..fd49d81 100644 --- a/app/content-scripts/lib/niceNames.js +++ b/app/content-scripts/lib/niceNames.js @@ -1,19 +1,4 @@ -module.exports = function niceNames () { - var ngScopeElts = document.getElementsByClassName('ng-scope'); - ngScopeElts = Array.prototype.slice.call(ngScopeElts); - return ngScopeElts. - map(angular.element). - reduce(accumulateElements, {}); - - function accumulateElements (acc, elt) { - acc[elt.scope().$id] = nameElement(elt); - return acc; - } - -}; - - var interestingAttributes = { 'ng-app': function (value) { // body... @@ -21,8 +6,8 @@ var interestingAttributes = { 'ng-controller': function (value) { // body... }, - 'ng-repeat': function (value) { - var match = /(.+) in/.exec(val); + 'ng-repeat': function (value, scope) { + var match = /(.+) in/.exec(value); var lhs = match[1]; match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/); @@ -35,13 +20,14 @@ var interestingAttributes = { } }; - function nameElement (element) { var scope = element.scope(), name = {}; Object.keys(interestingAttributes).forEach(function (attributeName) { - + var value = element.attr(attributeName); + value && (name[attributeName] = + interestingAttributes[attributeName](value, scope)); }) return Object.keys(name).length > 0 ? name : boringName(element); @@ -69,3 +55,17 @@ function parseAttributeValue (attr) { val = match[1]; } } + +module.exports = function niceNames () { + var ngScopeElts = document.getElementsByClassName('ng-scope'); + ngScopeElts = Array.prototype.slice.call(ngScopeElts); + return ngScopeElts. + map(angular.element). + reduce(accumulateElements, {}); + + function accumulateElements (acc, elt) { + acc[elt.scope().$id] = nameElement(elt); + return acc; + } + +}; \ No newline at end of file