Skip to content
This repository was archived by the owner on Jan 16, 2020. It is now read-only.

Commit 32bffb5

Browse files
committed
Fix for white-space nodes in FF and Chrome.
1 parent 74e7f64 commit 32bffb5

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

beta2/3collectionChange.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<body>
1616
<button onclick="showData()">show data</button>
1717

18-
<button onclick="setName()">set name</button>
18+
<button onclick="setLastName()">set last name</button>
1919
<button onclick="append()">append</button>
2020
<button onclick="deleteLast()">delete last row</button>
2121
<hr /><br />
@@ -104,8 +104,10 @@
104104

105105
});
106106

107-
function setName() {
108-
$.setField( people[0], "lastName", "Greenford" );
107+
function setLastName() {
108+
if ( people.length ) {
109+
$.setField( people[ people.length - 1 ], "lastName", "NewLastName" );
110+
}
109111
}
110112

111113
function append() {

beta2/4tmplRender.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<body>
1616
<button onclick="showData()">show data</button>
1717

18-
<button onclick="setName()">set name</button>
18+
<button onclick="setLastName()">set last name</button>
1919
<button onclick="append()">append</button>
2020
<button onclick="deleteLast()">delete last row</button>
2121
<hr /><br />
@@ -80,8 +80,10 @@ <h3>Read-only</h3>
8080

8181
});
8282

83-
function setName() {
84-
$.setField( people[0], "lastName", "Greenford" );
83+
function setLastName() {
84+
if ( people.length ) {
85+
$.setField( people[ people.length - 1 ], "lastName", "NewLastName" );
86+
}
8587
}
8688

8789
function append() {

beta2/jquery.datalink2.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,8 @@ function setViewItems( root, object ) {
477477
}
478478

479479
function processElem( el ) {
480-
var path = el.getAttribute( pathAttr ),
480+
var node = el,
481+
path = el.getAttribute( pathAttr ),
481482
binding = el.getAttribute( bindAttr );
482483

483484
if ( path ) {
@@ -486,9 +487,12 @@ function setViewItems( root, object ) {
486487
addItem( path, getLinkedPath( el.parentNode )[0]);
487488
}
488489
nodes.push( prevNode = el );
489-
} else if ( el.previousSibling === prevNode ) {
490-
el.setAttribute( pathAttr, prevPath );
491-
nodes.push( prevNode = el );
490+
} else {
491+
while ( (node = node.previousSibling) && node.nodeType !== 1 ) {} // TODO Later support intermediate text nodes
492+
if ( node === prevNode ) {
493+
el.setAttribute( pathAttr, prevPath );
494+
nodes.push( prevNode = el );
495+
}
492496
}
493497
if ( binding ) {
494498
bind.push( el );

beta2/simple-explicit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h3>Declarative</h3>
6969
});
7070
$(person).trigger("refresh");
7171
});
72-
72+
7373
$(person).bind("refresh", function() {
7474
$(".roleColor").css({
7575
backgroundColor: person.roleColor

0 commit comments

Comments
 (0)