mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-22 01:10:23 +00:00
fix ie bug with .text() on jqlite
This commit is contained in:
parent
8394353b85
commit
8e1b670d5b
5 changed files with 35 additions and 63 deletions
|
|
@ -136,7 +136,7 @@ Compiler.prototype = {
|
|||
// process markup for text nodes only
|
||||
eachTextNode(element, function(textNode){
|
||||
var text = textNode.text();
|
||||
foreach(self.textMarkup, function(markup){
|
||||
foreach(self.textMarkup, function(markup, name){
|
||||
markup.call(selfApi, text, textNode, element);
|
||||
});
|
||||
});
|
||||
|
|
@ -144,7 +144,7 @@ Compiler.prototype = {
|
|||
|
||||
if (directives) {
|
||||
// Process attributes/directives
|
||||
eachAttribute(element, function(value, name){
|
||||
eachAttribute(element, function(value){
|
||||
foreach(self.attrMarkup, function(markup){
|
||||
markup.call(selfApi, value, name, element);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -191,9 +191,9 @@ JQLite.prototype = {
|
|||
|
||||
text: function(value) {
|
||||
if (isDefined(value)) {
|
||||
this[0].textContent = value;
|
||||
this[0].nodeValue = value;
|
||||
}
|
||||
return this[0].textContent;
|
||||
return this[0].nodeValue;
|
||||
},
|
||||
|
||||
val: function(value) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ angularTextMarkup('{{}}', function(text, textNode, parentElement) {
|
|||
|
||||
// TODO: this should be widget not a markup
|
||||
angularTextMarkup('OPTION', function(text, textNode, parentElement){
|
||||
if (parentElement[0].nodeName == "OPTION") {
|
||||
if (nodeName(parentElement) == "OPTION") {
|
||||
var select = document.createElement('select');
|
||||
select.insertBefore(parentElement[0].cloneNode(true), null);
|
||||
if (!select.innerHTML.match(/<option(\s.*\s|\s)value\s*=\s*.*>.*<\/\s*option\s*>/gi)) {
|
||||
|
|
|
|||
3
test.sh
3
test.sh
|
|
@ -1,2 +1 @@
|
|||
java -jar lib/jstestdriver/JsTestDriver.jar --tests all | grep -v lib/jasmine
|
||||
|
||||
java -jar lib/jstestdriver/JsTestDriver.jar --tests BinderTest.testChangingSelectNonSelectedUpdatesModel
|
||||
|
|
|
|||
|
|
@ -1,62 +1,35 @@
|
|||
ParserTest.prototype.testReturnFunctionsAreNotBound = function(){
|
||||
var scope = createScope();
|
||||
scope.entity("Group", new DataStore());
|
||||
var Group = scope.$get("Group");
|
||||
assertEquals("eval Group", "function", typeof scope.$eval("Group"));
|
||||
assertEquals("direct Group", "function", typeof Group);
|
||||
assertEquals("eval Group.all", "function", typeof scope.$eval("Group.query"));
|
||||
assertEquals("direct Group.all", "function", typeof Group.query);
|
||||
};
|
||||
|
||||
ParserTest.prototype.XtestItShouldParseEmptyOnChangeAsNoop = function () {
|
||||
var scope = createScope();
|
||||
scope.watch("", function(){fail();});
|
||||
};
|
||||
|
||||
|
||||
ParserTest.prototype.XtestItShouldParseOnChangeIntoHashSet = function () {
|
||||
var scope = createScope({count:0});
|
||||
scope.watch("$anchor.a:count=count+1;$anchor.a:count=count+20;b:count=count+300");
|
||||
|
||||
scope.watchListeners["$anchor.a"].listeners[0]();
|
||||
assertEquals(1, scope.$get("count"));
|
||||
scope.watchListeners["$anchor.a"].listeners[1]();
|
||||
assertEquals(21, scope.$get("count"));
|
||||
scope.watchListeners["b"].listeners[0]({scope:scope});
|
||||
assertEquals(321, scope.$get("count"));
|
||||
};
|
||||
ParserTest.prototype.XtestItShouldParseOnChangeBlockIntoHashSet = function () {
|
||||
var scope = createScope({count:0});
|
||||
var listeners = {a:[], b:[]};
|
||||
scope.watch("a:{count=count+1;count=count+20;};b:count=count+300",
|
||||
function(n, fn){listeners[n].push(fn);});
|
||||
|
||||
assertEquals(1, scope.watchListeners.a.listeners.length);
|
||||
assertEquals(1, scope.watchListeners.b.listeners.length);
|
||||
scope.watchListeners["a"].listeners[0]();
|
||||
assertEquals(21, scope.$get("count"));
|
||||
scope.watchListeners["b"].listeners[0]();
|
||||
assertEquals(321, scope.$get("count"));
|
||||
};
|
||||
|
||||
FiltersTest.prototype.testBytes = function(){
|
||||
var controller = new FileController();
|
||||
assertEquals(angular.filter.bytes(123), '123 bytes');
|
||||
assertEquals(angular.filter.bytes(1234), '1.2 KB');
|
||||
assertEquals(angular.filter.bytes(1234567), '1.1 MB');
|
||||
};
|
||||
|
||||
BinderTest.prototype.testDissableAutoSubmit = function() {
|
||||
var c = this.compile('<input type="submit" value="S"/>', null, {autoSubmit:true});
|
||||
BinderTest.prototype.testExpandEntityTagWithName = function(){
|
||||
var c = this.compile('<div ng-entity="friend=Person"/>');
|
||||
assertEquals(
|
||||
'<input ng-action="$save()" ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}" type="submit" value="S"></input>',
|
||||
sortedHtml(c.node));
|
||||
|
||||
c = this.compile('<input type="submit" value="S"/>', null, {autoSubmit:false});
|
||||
assertEquals(
|
||||
'<input type="submit" value="S"></input>',
|
||||
'<div ng-entity="friend=Person" ng-watch="$anchor.friend:{friend=Person.load($anchor.friend);friend.$$anchor=\"friend\";};"></div>',
|
||||
sortedHtml(c.node));
|
||||
assertEquals("Person", c.scope.$get("friend.$entity"));
|
||||
assertEquals("friend", c.scope.$get("friend.$$anchor"));
|
||||
};
|
||||
|
||||
BinderTest.prototype.testExpandSubmitButtonToAction = function(){
|
||||
var html = this.compileToHtml('<input type="submit" value="Save">');
|
||||
assertTrue(html, html.indexOf('ng-action="$save()"') > 0 );
|
||||
assertTrue(html, html.indexOf('ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}"') > 0 );
|
||||
};
|
||||
|
||||
BinderTest.prototype.testReplaceFileUploadWithSwf = function(){
|
||||
expectAsserts(1);
|
||||
var form = jQuery("body").append('<div id="testTag"><input type="file"></div>');
|
||||
form.data('scope', new Scope());
|
||||
var factory = {};
|
||||
var binder = new Binder(form.get(0), factory, new MockLocation());
|
||||
factory.createController = function(node){
|
||||
assertEquals(node.attr('type'), 'file');
|
||||
return {updateModel:function(){}};
|
||||
};
|
||||
binder.compile();
|
||||
jQuery("#testTag").remove();
|
||||
};
|
||||
|
||||
BinderTest.prototype.testExpandEntityTagWithDefaults = function(){
|
||||
assertEquals(
|
||||
'<div ng-entity="Person:{a:\"a\"}" ng-watch=""></div>',
|
||||
this.compileToHtml('<div ng-entity=\'Person:{a:"a"}\'/>'));
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue