Skip to content

Commit

Permalink
Merge pull request #963 from bitovi/ie-2-1-fixes
Browse files Browse the repository at this point in the history
fixes IE8
  • Loading branch information
justinbmeyer committed May 5, 2014
2 parents b60c252 + efe7dbb commit 2a82b64
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 62 deletions.
12 changes: 8 additions & 4 deletions component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ steal("can/util", "can/view/callbacks","can/control", "can/observe", "can/view/m
can.each(this.constructor.attributeScopeMappings, function (val, prop) {
initalScopeData[prop] = el.getAttribute(can.hyphenate(val));
});

// Get the value in the scope for each attribute
// the hookup should probably happen after?
can.each(can.makeArray(el.attributes), function (node, index) {
Expand All @@ -132,7 +132,6 @@ steal("can/util", "can/view/callbacks","can/control", "can/observe", "can/view/m
return;
}
}

// Cross-bind the value in the scope to this
// component's scope
var computeData = hookupOptions.scope.computeData(value, {
Expand All @@ -152,7 +151,7 @@ steal("can/util", "can/view/callbacks","can/control", "can/observe", "can/view/m

// Set the value to be added to the scope
initalScopeData[name] = compute();

// We don't need to listen to the compute `change` if it doesn't have any dependencies
if (!compute.hasDependencies) {
compute.unbind("change", handler);
Expand Down Expand Up @@ -293,7 +292,12 @@ steal("can/util", "can/view/callbacks","can/control", "can/observe", "can/view/m
frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options));
} else {
// Otherwise render the contents between the
frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : "");
if(hookupOptions.templateType === "legacy") {
frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : "");
} else {
frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : document.createDocumentFragment();
}

}
// Append the resulting document fragment to the element
can.appendChild(el, frag);
Expand Down
3 changes: 2 additions & 1 deletion component/test.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE HTML>
<!doctype html>
<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=Edge"/>
<link rel="stylesheet" type="text/css" href="//code.jquery.com/qunit/qunit-1.14.0.css" />

<style>.active {
Expand Down
114 changes: 59 additions & 55 deletions route/pushstate/pushstate_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,65 +563,69 @@ steal('can/route/pushstate', "can/test", function () {
iframe.src = can.test.path("route/pushstate/testing.html");
can.$("#qunit-test-area")[0].appendChild(iframe);
});

test("no doubled history states (#656)", function () {
stop();
window.routeTestReady = function (iCanRoute, loc, hist, win) {
var root = loc.pathname.substr(0, loc.pathname.lastIndexOf("/") + 1);
var stateTest = -1,
message;

function nextStateTest() {
stateTest++;
win.can.route.attr("page", "start");

setTimeout(function () {
if (stateTest === 0) {
message = "can.route.attr";
win.can.route.attr("page", "test");
} else if (stateTest === 1) {
message = "history.pushState";
win.history.pushState(null, null, root + "test/");
} else if (stateTest === 2) {
message = "link click";
var link = win.document.createElement("a");
link.href = root + "test/";
link.innerText = "asdf";
win.document.body.appendChild(link);
win.can.trigger(win.can.$(link), "click");
} else {
start();
can.remove(can.$(iframe));
return;
}


if(window.parent === window) {
// we can't call back if running in multiple frames
test("no doubled history states (#656)", function () {
stop();
window.routeTestReady = function (iCanRoute, loc, hist, win) {
var root = loc.pathname.substr(0, loc.pathname.lastIndexOf("/") + 1);
var stateTest = -1,
message;

function nextStateTest() {
stateTest++;
win.can.route.attr("page", "start");

setTimeout(function () {
win.history.back();
if (stateTest === 0) {
message = "can.route.attr";
win.can.route.attr("page", "test");
} else if (stateTest === 1) {
message = "history.pushState";
win.history.pushState(null, null, root + "test/");
} else if (stateTest === 2) {
message = "link click";
var link = win.document.createElement("a");
link.href = root + "test/";
link.innerText = "asdf";
win.document.body.appendChild(link);
win.can.trigger(win.can.$(link), "click");
} else {
start();
can.remove(can.$(iframe));
return;
}

setTimeout(function () {
var path = win.location.pathname;
// strip root for deparam
if (path.indexOf(root) === 0) {
path = path.substr(root.length);
}
equal(win.can.route.deparam(path)
.page, "start", message + " passed");
nextStateTest();
win.history.back();
setTimeout(function () {
var path = win.location.pathname;
// strip root for deparam
if (path.indexOf(root) === 0) {
path = path.substr(root.length);
}
equal(win.can.route.deparam(path)
.page, "start", message + " passed");
nextStateTest();
}, 200);
}, 200);

}, 200);

}, 200);
}

win.can.route.bindings.pushstate.root = root;
win.can.route(":page/");
win.can.route.ready();
nextStateTest();
};

var iframe = document.createElement("iframe");
iframe.src = can.test.path("route/pushstate/testing.html");
can.$("#qunit-test-area")[0].appendChild(iframe);
});
}

win.can.route.bindings.pushstate.root = root;
win.can.route(":page/");
win.can.route.ready();
nextStateTest();
};

var iframe = document.createElement("iframe");
iframe.src = can.test.path("route/pushstate/testing.html");
can.$("#qunit-test-area")[0].appendChild(iframe);
});

}

test("routed links must descend from pushstate root (#652)", 1, function () {

Expand Down
7 changes: 5 additions & 2 deletions view/mustache/mustache_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3712,6 +3712,7 @@ steal("can/model", "can/view/mustache", "can/test", "can/view/mustache/spec/spec
})

test("can.Construct derived classes should be considered objects, not functions (#450)", 8, function() {

can.Mustache.registerHelper("cat", function(options) {
var clazz = options.hash ? options.hash.clazz : options;
// When using the anonymous function containing foostructor, it will need to be executed
Expand All @@ -3727,6 +3728,7 @@ steal("can/model", "can/view/mustache", "can/test", "can/view/mustache/spec/spec
},
div = document.createElement("div"),
description;

foostructor.self = foostructor;
window.other_text = "Window context";

Expand All @@ -3751,14 +3753,15 @@ steal("can/model", "can/view/mustache", "can/test", "can/view/mustache/spec/spec
var content = div.getElementsByTagName('div');

description = " (constructor by itself)";

equal(content[0].innerHTML, "bar", "fully dotted" + description);
equal(content[1].innerHTML.replace(/<\/?span>/g,''), "", "with attribute nested" + description);
equal(content[1].innerHTML.replace(/<\/?span>/ig,''), "", "with attribute nested" + description);
equal(content[2].innerHTML, "bar", "passed as an argument to helper" + description);
equal(content[3].innerHTML, "bar", "passed as a hash to helper" + description);

description = " (constructor as function returning itself)";
equal(content[4].innerHTML, "bar", "fully dotted" + description);
equal(content[5].innerHTML.replace(/<\/?span>/g,''), "", "with attribute nested" + description);
equal(content[5].innerHTML.replace(/<\/?span>/ig,''), "", "with attribute nested" + description);
equal(content[6].innerHTML, "bar", "passed as an argument to helper" + description);
equal(content[7].innerHTML, "bar", "passed as a hash to helper" + description);
});
Expand Down
3 changes: 3 additions & 0 deletions view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ steal('can/util', function (can) {
// #### fragment
// this is used internally to create a document fragment, insert it,then hook it up
fragment: function (result) {
if(typeof result !== "string" && result.nodeType === 11) {
return result;
}
var frag = can.buildFragment(result, document.body);
// If we have an empty frag...
if (!frag.childNodes.length) {
Expand Down

0 comments on commit 2a82b64

Please sign in to comment.