@@ -205,7 +205,7 @@ function stepper(forms) {
206 // assumes that there is a next element
206 // assumes that there is a next element
207 function next(ctx) {
207 function next(ctx) {
208− while (!ps[0].peekNext()) { ps.shift(); matrices.pop(); ctx.restore(); }
208+ while (!ps[0].peekNext()) { ps.shift(); matrices.pop(); if (ctx) { ctx.restore(); } }
209 var out = ps[0].next();
209 var out = ps[0].next();
210 var f = out.form;
210 var f = out.form;
211 if (f.ctor === 'FGroup') {
211 if (f.ctor === 'FGroup') {
@@ -254,12 +254,13 @@ function updateTracker(w,h,div) {
255 function getContext(transforms) {
255 function getContext(transforms) {
256 while (i < kids.length) {
256 while (i < kids.length) {
257− var node = kids[i++];
257+ var node = kids[i];
258 if (node.getContext) {
258 if (node.getContext) {
259 node.width = w;
259 node.width = w;
260 node.height = h;
260 node.height = h;
261 node.style.width = w + 'px';
261 node.style.width = w + 'px';
262 node.style.height = h + 'px';
262 node.style.height = h + 'px';
263 return transform(transforms, node.getContext('2d'));
264 return transform(transforms, node.getContext('2d'));
265 div.removeChild(node);
266 div.removeChild(node);
@@ -277,16 +278,10 @@ function updateTracker(w,h,div) {
277 container.style.overflow = 'hidden';
278 container.style.overflow = 'hidden';
278 container.style.position = 'absolute';
279 container.style.position = 'absolute';
279 addTransform(container.style, 'scaleY(-1)');
280 addTransform(container.style, 'scaleY(-1)');
280− if (!container) {
281+
281− div.appendChild(container);
283− var kid = kids[i];
282+ var kid = kids[i];
285− div.insertBefore(container, kid);
283+ kid ? div.insertBefore(container, kid)
287− div.appendChild(container);
284+ : div.appendChild(container);
291 // we have added a new node, so we must step our position
286 // we have added a new node, so we must step our position
@@ -307,7 +302,7 @@ function updateTracker(w,h,div) {
307 addTransform(node.style, makeTransform(w, h, form, matrices));
302 addTransform(node.style, makeTransform(w, h, form, matrices));
309 function clearRest() {
304 function clearRest() {
310− while (kids.length > i) {
305+ while (i < kids.length) {
311 div.removeChild(kids[i]);
306 div.removeChild(kids[i]);