mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
binding() should return value for input/text area, innerHTML for the rest
This commit is contained in:
parent
5c887ddb66
commit
aec3c8478c
2 changed files with 24 additions and 1 deletions
|
|
@ -167,7 +167,12 @@ angular.scenario.dsl('binding', function() {
|
|||
var element = new elements.init(elements[i]);
|
||||
if (contains(element.attr('ng:bind'), name) ||
|
||||
contains(element.attr('ng:bind-template'), name)) {
|
||||
done(null, element.text());
|
||||
if (element.is('input, textarea')) {
|
||||
done(null, element.val());
|
||||
} else {
|
||||
console.log('element.html(): ', element.html());
|
||||
done(null, element.html());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,6 +376,24 @@ describe("angular.scenario.dsl", function() {
|
|||
expect($root.futureResult).toEqual('some value');
|
||||
});
|
||||
|
||||
it('should return value for input elements', function() {
|
||||
doc.append('<input type="text" class="ng-binding" ng:bind="foo.bar" value="some value"/>');
|
||||
$root.dsl.binding('foo.bar');
|
||||
expect($root.futureResult).toEqual('some value');
|
||||
});
|
||||
|
||||
it('should return value for textarea elements', function() {
|
||||
doc.append('<textarea class="ng-binding" ng:bind="foo.bar">some value</textarea>');
|
||||
$root.dsl.binding('foo.bar');
|
||||
expect($root.futureResult).toEqual('some value');
|
||||
});
|
||||
|
||||
it('should return innerHTML for all the other elements', function() {
|
||||
doc.append('<div class="ng-binding" ng:bind="foo.bar">some <b>value</b></div>');
|
||||
$root.dsl.binding('foo.bar');
|
||||
expect($root.futureResult).toEqual('some <b>value</b>');
|
||||
});
|
||||
|
||||
it('should select binding in template by name', function() {
|
||||
doc.append('<pre class="ng-binding" ng:bind-template="foo {{bar}} baz">foo some baz</pre>');
|
||||
$root.dsl.binding('bar');
|
||||
|
|
|
|||
Loading…
Reference in a new issue