Skip to content
Permalink
Browse files

fixes to container passing

  • Loading branch information...
bevacqua committed Feb 29, 2016
1 parent 03525aa commit a00ad8ec53ee64ab2b82b0feab1a7b6bba8e4414
Showing with 12 additions and 6 deletions.
  1. +4 −0 CHANGELOG.md
  2. +8 −6 browser/view.js
@@ -1,3 +1,7 @@
# v8.0.6 Model

- Fixed a long-standing bug where partials appended to other places would emit events using the wrong `container`

# v8.0.6 Box

- Introduced `taunus.partial.afterOf` method
@@ -106,11 +106,14 @@ function insert (container, html) {
}

function replacer (html, next) {
var first;
var placeholder = doc.createElement('div');
placeholder.innerHTML = html;
while (placeholder.children.length) {
first = placeholder.children[0];
next(placeholder);
}
return first;
}

function replace (container, html) {
@@ -127,26 +130,25 @@ function replace (container, html) {

function afterOf (el, html) {
if (el.nextSibling) {
beforeOf(el.nextSibling, html);
} else {
appendTo(el.parentElement, html);
return beforeOf(el.nextSibling, html);
}
return appendTo(el.parentElement, html);
}

function beforeOf (el, html) {
replacer(html, function append (p) {
return replacer(html, function append (p) {
el.parentElement.insertBefore(lastChild(p), el);
});
}

function appendTo (container, html) {
replacer(html, function append (p) {
return replacer(html, function append (p) {
container.appendChild(lastChild(p));
});
}

function prependTo (container, html) {
beforeOf(container.firstChild, html);
return beforeOf(container.firstChild, html);
}

function lastChild (p) { return p.children[p.children.length - 1]; }

0 comments on commit a00ad8e

Please sign in to comment.
You can’t perform that action at this time.