tests work under jquery and without

This commit is contained in:
Misko Hevery
2010-04-22 17:11:56 -07:00
parent 2a9669e1d8
commit fe434307d1
11 changed files with 36 additions and 30 deletions

View File

@@ -112,7 +112,11 @@ 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 isElement(node) {
return node && (node.nodeName || node instanceof JQLite || node instanceof jQuery);
return node && (node.nodeName || node instanceof JQLite || (jQuery && node instanceof jQuery));
}
function HTML(html) {
this.html = html;
}
if (msie) {

View File

@@ -30,8 +30,8 @@ angularDirective("ng-bind", function(expression){
value = this.$tryEval(expression, function(e){
error = toJson(e);
}),
isElem = isElement(value);
if (!isElem && isObject(value)) {
isHtml = value instanceof HTML;
if (!isHtml && isObject(value)) {
value = toJson(value);
}
if (value != lastValue || error != lastError) {
@@ -39,9 +39,8 @@ angularDirective("ng-bind", function(expression){
lastError = error;
elementError(element, NG_EXCEPTION, error);
if (error) value = error;
if (isElem) {
element.html('');
element.append(value);
if (isHtml) {
element.html(value.html);
} else {
element.text(value);
}

View File

@@ -269,9 +269,7 @@ foreach({
},
'html': function(html){
var div = jqLite('div');
div.html(html);
return div.children();
return new HTML(html);
},
'linky': function(text){
@@ -293,7 +291,7 @@ foreach({
raw = raw.substring(i + url.length);
}
html.push(escapeHtml(raw));
return jqLite(html.join(''));
return new HTML(html.join(''));
}
}, function(v,k){angularFilter[k] = v;});

View File

@@ -238,10 +238,6 @@ 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);
}
});

View File

@@ -32,7 +32,7 @@ function valueAccessor(scope, element) {
value = element.val();
force = true;
}
if (element[0].disabled || isString(element.attr('readonly'))) {
if (element[0].disabled || element[0].readOnly) {
elementError(element, NG_VALIDATION_ERROR, null);
invalidWidgets.markValid(element);
return value;