Use nodeType===11 for cross-browser DocumentFragment test. Thanks David.

This commit is contained in:
Nick Martin
2012-01-13 13:21:08 -08:00
parent 85742619d9
commit 75e387aaa0
2 changed files with 4 additions and 8 deletions

View File

@@ -5,8 +5,7 @@ Sky.ui = Sky.ui || {};
// the range tag to operate on. In the latter case, the range itself
// will be destroyed along with its subranges.
Sky.ui._cleanup = function (what, tag) {
if (typeof DocumentFragment !== 'undefined' ?
what instanceof DocumentFragment : what instanceof HTMLDocument)
if (typeof what === 'object' && what.nodeType === 11 /* DocumentFragment */)
what = new Sky.ui._LiveRange(tag, what.firstChild, what.lastChild);
var ranges = [];
@@ -70,8 +69,7 @@ Sky.ui.render = function (render_func, events, event_data) {
var frag;
// Coerce to a document fragment
if (typeof DocumentFragment !== 'undefined' ?
result instanceof DocumentFragment : result instanceof HTMLDocument)
if (typeof what === 'object' && what.nodeType === 11 /* DocumentFragment */)
frag = result;
else if (isNode(result)) {
frag = document.createDocumentFragment();

View File

@@ -99,8 +99,7 @@ var dump = function (what, tag) {
ret += (is_start ? "<": "</") + obj.id + ">";
};
if (typeof DocumentFragment !== 'undefined' ?
what instanceof DocumentFragment : what instanceof HTMLDocument) {
if (typeof what === 'object' && what.nodeType === 11 /* DocumentFragment */) {
if (what.firstChild) {
var range = new Sky.ui._LiveRange(tag || 'a', what);
range.visit(emit, emit);
@@ -371,8 +370,7 @@ var test_single = function () {
assert(f.lastChild, r_b.lastNode());
var ret1 = r_a.replace_contents(frag("<div id=2></div>"));
assert(true, typeof DocumentFragment !== 'undefined' ?
ret1 instanceof DocumentFragment : ret1 instanceof HTMLDocument);
assert(true, ret1.nodeType === 11 /* DocumentFragment */);
assert_dump("<1></1>", ret1);
assert_dump("<a><2></2></a>", r_a);
assert_dump("<b><a><2></2></a></b>", r_b);