aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js15
-rw-r--r--src/directives.js2
-rw-r--r--src/jqLite.js15
-rw-r--r--src/widgets.js19
4 files changed, 37 insertions, 14 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 613aee67..11ac7c1c 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -27,7 +27,8 @@ var consoleNode,
angularFilter = extensionMap(angular, 'filter'),
angularFormatter = extensionMap(angular, 'formatter'),
angularService = extensionMap(angular, 'service'),
- angularCallbacks = extensionMap(angular, 'callbacks');
+ angularCallbacks = extensionMap(angular, 'callbacks'),
+ nodeName;
function angularAlert(){
log(arguments); window.alert.apply(window, arguments);
@@ -110,13 +111,23 @@ function isTextNode(node) { return nodeName(node) == '#text'; }
function lowercase(value){ return isString(value) ? value.toLowerCase() : value; }
function uppercase(value){ return isString(value) ? value.toUpperCase() : value; }
function trim(value) { return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value; }
-function nodeName(element) { return (element[0] || element).nodeName; }
function isElement(node) {
if (node && !node.item && isDefined(node.length) && isDefined(node[0]))
node = node[0];
return node && node.nodeName;
}
+if (msie) {
+ nodeName = function(element) {
+ element = element[0] || element;
+ return (element.scopeName && element.scopeName != 'HTML' ) ? uppercase(element.scopeName + ':' + element.nodeName) : element.nodeName;
+ };
+} else {
+ nodeName = function(element) {
+ return (element[0] || element).nodeName;
+ };
+}
+
function isVisible(element) {
var rect = element[0].getBoundingClientRect(),
width = (rect.width || (rect.right||0 - rect.left||0)),
diff --git a/src/directives.js b/src/directives.js
index 2f393b5d..bdcdcc1d 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -109,7 +109,7 @@ angularDirective("ng-bind-attr", function(expression){
var value = compileBindTemplate(bindExp).call(this, element);
if (REMOVE_ATTRIBUTES[lowercase(key)]) {
if (!toBoolean(value)) {
- element.removeAttr('disabled');
+ element.removeAttr(key);
} else {
element.attr(key, value);
}
diff --git a/src/jqLite.js b/src/jqLite.js
index 1bf6e083..0867f9c9 100644
--- a/src/jqLite.js
+++ b/src/jqLite.js
@@ -185,7 +185,9 @@ JQLite.prototype = {
} else if (isDefined(value)) {
e.setAttribute(name, value);
} else {
- return e.getAttribute ? e.getAttribute(name) : undefined;
+ var attributes = e.attributes,
+ item = attributes ? attributes.getNamedItem(name) : undefined;
+ return item ? item.value : undefined;
}
},
@@ -205,8 +207,11 @@ JQLite.prototype = {
html: function(value) {
if (isDefined(value)) {
- for ( var i = 0, children = this[0].childNodes; i < children.length; i++) {
- jqLite(children[i]).dealoc();
+ var parent = this[0], child;
+ while(parent.childNodes.length) {
+ child = parent.childNodes[0];
+ jqLite(child).dealoc();
+ parent.removeChild(child);
}
this[0].innerHTML = value;
}
@@ -229,6 +234,10 @@ if (msie) {
},
trigger: function(type) {
+
+ if (nodeName(this) == 'INPUT' && (lowercase(this.attr('type')) == 'radio' || lowercase(this.attr('type')) == 'checkbox')) {
+ this[0].checked = ! this[0].checked;
+ }
this[0].fireEvent('on' + type);
}
});
diff --git a/src/widgets.js b/src/widgets.js
index b296c354..2c084e29 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -211,24 +211,25 @@ angularWidget('NG:INCLUDE', function(element){
}
});
-angularWidget('NG:SWITCH', function ngSwitch(element){
+var ngSwitch = angularWidget('NG:SWITCH', function (element){
var compiler = this,
watchExpr = element.attr("on"),
- whenExpr = (element.attr("using") || 'equals').split(":"),
- whenFn = ngSwitch[whenExpr.shift()],
+ usingExpr = (element.attr("using") || 'equals'),
+ usingExprParams = usingExpr.split(":");
+ usingFn = ngSwitch[usingExprParams.shift()],
changeExpr = element.attr('change') || '',
cases = [];
- if (!whenFn) throw "Using expression '" + usingExpr + "' unknown.";
+ if (!usingFn) throw "Using expression '" + usingExpr + "' unknown.";
eachNode(element, function(caseElement){
var when = caseElement.attr('ng-switch-when');
if (when) {
cases.push({
when: function(scope, value){
var args = [value, when];
- foreach(whenExpr, function(arg){
+ foreach(usingExprParams, function(arg){
args.push(arg);
});
- return whenFn.apply(scope, args);
+ return usingFn.apply(scope, args);
},
change: changeExpr,
element: caseElement,
@@ -236,6 +237,7 @@ angularWidget('NG:SWITCH', function ngSwitch(element){
});
}
});
+
element.html('');
return function(element){
var scope = this, childScope;
@@ -244,9 +246,10 @@ angularWidget('NG:SWITCH', function ngSwitch(element){
childScope = createScope(scope);
foreach(cases, function(switchCase){
if (switchCase.when(childScope, value)) {
- element.append(switchCase.element);
+ var caseElement = switchCase.element.clone();
+ element.append(caseElement);
childScope.$tryEval(switchCase.change, element);
- switchCase.template(switchCase.element, childScope);
+ switchCase.template(caseElement, childScope);
if (scope.$invalidWidgets)
scope.$invalidWidgets.clearOrphans();
childScope.$init();