Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8e1b670

Browse files
committed
fix ie bug with .text() on jqlite
1 parent 8394353 commit 8e1b670

File tree

5 files changed

+32
-60
lines changed

5 files changed

+32
-60
lines changed

src/Compiler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ Compiler.prototype = {
136136
// process markup for text nodes only
137137
eachTextNode(element, function(textNode){
138138
var text = textNode.text();
139-
foreach(self.textMarkup, function(markup){
139+
foreach(self.textMarkup, function(markup, name){
140140
markup.call(selfApi, text, textNode, element);
141141
});
142142
});
143143
}
144144

145145
if (directives) {
146146
// Process attributes/directives
147-
eachAttribute(element, function(value, name){
147+
eachAttribute(element, function(value){
148148
foreach(self.attrMarkup, function(markup){
149149
markup.call(selfApi, value, name, element);
150150
});

src/jqLite.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ JQLite.prototype = {
191191

192192
text: function(value) {
193193
if (isDefined(value)) {
194-
this[0].textContent = value;
194+
this[0].nodeValue = value;
195195
}
196-
return this[0].textContent;
196+
return this[0].nodeValue;
197197
},
198198

199199
val: function(value) {

src/markups.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ angularTextMarkup('{{}}', function(text, textNode, parentElement) {
5353

5454
// TODO: this should be widget not a markup
5555
angularTextMarkup('OPTION', function(text, textNode, parentElement){
56-
if (parentElement[0].nodeName == "OPTION") {
56+
if (nodeName(parentElement) == "OPTION") {
5757
var select = document.createElement('select');
5858
select.insertBefore(parentElement[0].cloneNode(true), null);
5959
if (!select.innerHTML.match(/<option(\s.*\s|\s)value\s*=\s*.*>.*<\/\s*option\s*>/gi)) {

test.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
java -jar lib/jstestdriver/JsTestDriver.jar --tests all | grep -v lib/jasmine
2-
1+
java -jar lib/jstestdriver/JsTestDriver.jar --tests BinderTest.testChangingSelectNonSelectedUpdatesModel

test/moveToAngularCom/miscTest.js

+26-53
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,35 @@
1-
ParserTest.prototype.testReturnFunctionsAreNotBound = function(){
2-
var scope = createScope();
3-
scope.entity("Group", new DataStore());
4-
var Group = scope.$get("Group");
5-
assertEquals("eval Group", "function", typeof scope.$eval("Group"));
6-
assertEquals("direct Group", "function", typeof Group);
7-
assertEquals("eval Group.all", "function", typeof scope.$eval("Group.query"));
8-
assertEquals("direct Group.all", "function", typeof Group.query);
9-
};
10-
11-
ParserTest.prototype.XtestItShouldParseEmptyOnChangeAsNoop = function () {
12-
var scope = createScope();
13-
scope.watch("", function(){fail();});
14-
};
15-
16-
17-
ParserTest.prototype.XtestItShouldParseOnChangeIntoHashSet = function () {
18-
var scope = createScope({count:0});
19-
scope.watch("$anchor.a:count=count+1;$anchor.a:count=count+20;b:count=count+300");
20-
21-
scope.watchListeners["$anchor.a"].listeners[0]();
22-
assertEquals(1, scope.$get("count"));
23-
scope.watchListeners["$anchor.a"].listeners[1]();
24-
assertEquals(21, scope.$get("count"));
25-
scope.watchListeners["b"].listeners[0]({scope:scope});
26-
assertEquals(321, scope.$get("count"));
1+
BinderTest.prototype.testExpandEntityTagWithName = function(){
2+
var c = this.compile('<div ng-entity="friend=Person"/>');
3+
assertEquals(
4+
'<div ng-entity="friend=Person" ng-watch="$anchor.friend:{friend=Person.load($anchor.friend);friend.$$anchor=\"friend\";};"></div>',
5+
sortedHtml(c.node));
6+
assertEquals("Person", c.scope.$get("friend.$entity"));
7+
assertEquals("friend", c.scope.$get("friend.$$anchor"));
278
};
28-
ParserTest.prototype.XtestItShouldParseOnChangeBlockIntoHashSet = function () {
29-
var scope = createScope({count:0});
30-
var listeners = {a:[], b:[]};
31-
scope.watch("a:{count=count+1;count=count+20;};b:count=count+300",
32-
function(n, fn){listeners[n].push(fn);});
339

34-
assertEquals(1, scope.watchListeners.a.listeners.length);
35-
assertEquals(1, scope.watchListeners.b.listeners.length);
36-
scope.watchListeners["a"].listeners[0]();
37-
assertEquals(21, scope.$get("count"));
38-
scope.watchListeners["b"].listeners[0]();
39-
assertEquals(321, scope.$get("count"));
10+
BinderTest.prototype.testExpandSubmitButtonToAction = function(){
11+
var html = this.compileToHtml('<input type="submit" value="Save">');
12+
assertTrue(html, html.indexOf('ng-action="$save()"') > 0 );
13+
assertTrue(html, html.indexOf('ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}"') > 0 );
4014
};
4115

42-
FiltersTest.prototype.testBytes = function(){
43-
var controller = new FileController();
44-
assertEquals(angular.filter.bytes(123), '123 bytes');
45-
assertEquals(angular.filter.bytes(1234), '1.2 KB');
46-
assertEquals(angular.filter.bytes(1234567), '1.1 MB');
16+
BinderTest.prototype.testReplaceFileUploadWithSwf = function(){
17+
expectAsserts(1);
18+
var form = jQuery("body").append('<div id="testTag"><input type="file"></div>');
19+
form.data('scope', new Scope());
20+
var factory = {};
21+
var binder = new Binder(form.get(0), factory, new MockLocation());
22+
factory.createController = function(node){
23+
assertEquals(node.attr('type'), 'file');
24+
return {updateModel:function(){}};
25+
};
26+
binder.compile();
27+
jQuery("#testTag").remove();
4728
};
4829

49-
BinderTest.prototype.testDissableAutoSubmit = function() {
50-
var c = this.compile('<input type="submit" value="S"/>', null, {autoSubmit:true});
51-
assertEquals(
52-
'<input ng-action="$save()" ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}" type="submit" value="S"></input>',
53-
sortedHtml(c.node));
54-
55-
c = this.compile('<input type="submit" value="S"/>', null, {autoSubmit:false});
30+
BinderTest.prototype.testExpandEntityTagWithDefaults = function(){
5631
assertEquals(
57-
'<input type="submit" value="S"></input>',
58-
sortedHtml(c.node));
32+
'<div ng-entity="Person:{a:\"a\"}" ng-watch=""></div>',
33+
this.compileToHtml('<div ng-entity=\'Person:{a:"a"}\'/>'));
5934
};
6035

61-
62-

0 commit comments

Comments
 (0)