mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
change everything over to jasmine
This commit is contained in:
parent
038a743e6f
commit
0305b6746e
3 changed files with 18 additions and 4 deletions
|
|
@ -127,10 +127,11 @@ function createScope(parent, services, existing) {
|
|||
var watch = expressionCompile(watchExp),
|
||||
last;
|
||||
function watcher(){
|
||||
var value = watch.call(instance);
|
||||
var value = watch.call(instance),
|
||||
lastValue = last;
|
||||
if (last !== value) {
|
||||
last = value;
|
||||
instance.$tryEval(listener, exceptionHandler, value, last);
|
||||
instance.$tryEval(listener, exceptionHandler, value, lastValue);
|
||||
}
|
||||
}
|
||||
instance.$onEval(PRIORITY_WATCH, watcher);
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ angularDirective("ng-bind", function(expression){
|
|||
value = this.$tryEval(expression, function(e){
|
||||
error = toJson(e);
|
||||
}),
|
||||
isHtml = value instanceof HTML;
|
||||
if (!isHtml && isObject(value)) {
|
||||
isHtml = value instanceof HTML,
|
||||
isDomElement = isElement(value);
|
||||
if (!isHtml && !isDomElement && isObject(value)) {
|
||||
value = toJson(value);
|
||||
}
|
||||
if (value != lastValue || error != lastError) {
|
||||
|
|
@ -41,6 +42,9 @@ angularDirective("ng-bind", function(expression){
|
|||
if (error) value = error;
|
||||
if (isHtml) {
|
||||
element.html(value.html);
|
||||
} else if (isDomElement) {
|
||||
element.html('');
|
||||
element.append(value);
|
||||
} else {
|
||||
element.text(value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,15 @@ describe("directives", function(){
|
|||
expect(lowercase(element.html())).toEqual('<div>hello</div>');
|
||||
});
|
||||
|
||||
it('should ng-bind element', function() {
|
||||
angularFilter.myElement = function() {
|
||||
return jqLite('<a>hello</a>');
|
||||
};
|
||||
var scope = compile('<div ng-bind="0|myElement"></div>');
|
||||
scope.$eval();
|
||||
expect(lowercase(element.html())).toEqual('<a>hello</a>');
|
||||
});
|
||||
|
||||
it('should ng-bind-template', function() {
|
||||
var scope = compile('<div ng-bind-template="Hello {{name}}!"></div>');
|
||||
scope.$set('name', 'Misko');
|
||||
|
|
|
|||
Loading…
Reference in a new issue