From 3e33191596370190731a3cf1a354fd43ae306e8b Mon Sep 17 00:00:00 2001 From: Michel Boudreau Date: Thu, 12 Feb 2015 12:18:42 +1100 Subject: [PATCH 1/3] Fixing ng-jq issue with getting ng attribute --- src/Angular.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Angular.js b/src/Angular.js index 0a64cd016273..617f93330bd3 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -941,21 +941,22 @@ var csp = function() { ``` */ var jq = function() { - if (isDefined(jq.name_)) return jq.name_; - var el; - var i, ii = ngAttrPrefixes.length; - for (i = 0; i < ii; ++i) { - if (el = document.querySelector('[' + ngAttrPrefixes[i].replace(':', '\\:') + 'jq]')) { - break; - } - } - - var name; - if (el) { - name = getNgAttribute(el, "jq"); - } - - return (jq.name_ = name); + if (isDefined(jq.name_)) return jq.name_; + var el; + var i, ii = ngAttrPrefixes.length, prefix; + for (i = 0; i < ii; ++i) { + prefix = ngAttrPrefixes[i]; + if (el = document.querySelector('[' + prefix.replace(':', '\\:') + 'jq]')) { + break; + } + } + + var name; + if (el) { + name = el.getAttribute(prefix + 'jq'); + } + + return (jq.name_ = name); }; function concat(array1, array2, index) { From 2323a65d723b30339f625af21ab99a9455c2b1f2 Mon Sep 17 00:00:00 2001 From: Michel Boudreau Date: Mon, 16 Feb 2015 09:28:24 +1100 Subject: [PATCH 2/3] fixing indentation to spaces --- src/Angular.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Angular.js b/src/Angular.js index 617f93330bd3..e75c4bcaa400 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -941,22 +941,22 @@ var csp = function() { ``` */ var jq = function() { - if (isDefined(jq.name_)) return jq.name_; - var el; - var i, ii = ngAttrPrefixes.length, prefix; - for (i = 0; i < ii; ++i) { - prefix = ngAttrPrefixes[i]; - if (el = document.querySelector('[' + prefix.replace(':', '\\:') + 'jq]')) { - break; - } - } - - var name; - if (el) { - name = el.getAttribute(prefix + 'jq'); - } - - return (jq.name_ = name); + if (isDefined(jq.name_)) return jq.name_; + var el; + var i, ii = ngAttrPrefixes.length, prefix; + for (i = 0; i < ii; ++i) { + prefix = ngAttrPrefixes[i]; + if (el = document.querySelector('[' + prefix.replace(':', '\\:') + 'jq]')) { + break; + } + } + + var name; + if (el) { + name = el.getAttribute(prefix + 'jq'); + } + + return (jq.name_ = name); }; function concat(array1, array2, index) { From 3435e865e8903d4dbb1f27c3639c3605c25804cc Mon Sep 17 00:00:00 2001 From: Michel Boudreau Date: Mon, 16 Feb 2015 09:57:03 +1100 Subject: [PATCH 3/3] fixed getNgAttributes to not sure angular.element --- src/Angular.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Angular.js b/src/Angular.js index e75c4bcaa400..5702d0e83b71 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -943,19 +943,15 @@ var csp = function() { var jq = function() { if (isDefined(jq.name_)) return jq.name_; var el; - var i, ii = ngAttrPrefixes.length, prefix; + var i, ii = ngAttrPrefixes.length, prefix, name; for (i = 0; i < ii; ++i) { prefix = ngAttrPrefixes[i]; if (el = document.querySelector('[' + prefix.replace(':', '\\:') + 'jq]')) { + name = el.getAttribute(prefix + 'jq'); break; } } - var name; - if (el) { - name = el.getAttribute(prefix + 'jq'); - } - return (jq.name_ = name); }; @@ -1196,10 +1192,9 @@ var ngAttrPrefixes = ['ng-', 'data-ng-', 'ng:', 'x-ng-']; function getNgAttribute(element, ngAttr) { var attr, i, ii = ngAttrPrefixes.length; - element = jqLite(element); for (i = 0; i < ii; ++i) { attr = ngAttrPrefixes[i] + ngAttr; - if (isString(attr = element.attr(attr))) { + if (isString(attr = element.getAttribute(attr))) { return attr; } }