Skip to content

Commit

Permalink
adjust morph usage to be inclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
krisselden authored and rwjblue committed Feb 15, 2015
1 parent 51d17a6 commit a4590c8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
7 changes: 6 additions & 1 deletion packages/ember-metal-views/lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ Renderer.prototype.appendAttrTo =

Renderer.prototype.replaceIn =
function Renderer_replaceIn(view, target) {
var morph = this._dom.createMorph(target, null, null);
var morph;
if (target.firstNode) {
morph = this._dom.createMorph(target, target.firstNode, target.lastNode);
} else {
morph = this._dom.appendMorph(target);
}
this.scheduleInsert(view, morph);
};

Expand Down
8 changes: 3 additions & 5 deletions packages/ember-metal-views/tests/test_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ MetalRenderer.prototype.createElement = function (view, contextualElement) {
}
}
if (view.childViews) {
view._childViewsMorph = this._dom.createMorph(el, null, null);
view._childViewsMorph = this._dom.appendMorph(el);
} else if (view.textContent) {
setElementText(el, view.textContent);
} else if (view.innerHTML) {
this._dom.detectNamespace(el);
var nodes = this._dom.parseHTML(view.innerHTML, el);
while (nodes[0]) {
el.appendChild(nodes[0]);
}
var frag = this._dom.parseHTML(view.innerHTML, el);
el.appendChild(frag);
}
return el;
};
Expand Down
7 changes: 2 additions & 5 deletions packages/ember-views/lib/system/render_buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,8 @@ RenderBuffer.prototype = {
if (content.nodeType) {
this._element.appendChild(content);
} else {
var nodes;
nodes = this.dom.parseHTML(content, contextualElement);
while (nodes[0]) {
this._element.appendChild(nodes[0]);
}
var frag = this.dom.parseHTML(content, contextualElement);
this._element.appendChild(frag);
}

// This should only happen with legacy string buffers
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-views/lib/system/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function isSimpleClick(event) {
*/
function getViewRange(view) {
var range = document.createRange();
range.setStartAfter(view._morph.start);
range.setEndBefore(view._morph.end);
range.setStartBefore(view._morph.firstNode);
range.setEndAfter(view._morph.lastNode);
return range;
}

Expand Down
8 changes: 1 addition & 7 deletions packages/ember-views/lib/views/container_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,7 @@ var ContainerView = View.extend(MutableArray, {
var element = buffer.element();
var dom = buffer.dom;

if (this.tagName === '') {
element = dom.createDocumentFragment();
buffer._element = element;
this._childViewsMorph = dom.appendMorph(element, this._morph.contextualElement);
} else {
this._childViewsMorph = dom.createMorph(element, element.lastChild, null);
}
this._childViewsMorph = dom.appendMorph(element);

return element;
},
Expand Down

0 comments on commit a4590c8

Please sign in to comment.