Skip to content

Commit

Permalink
[BUGFIX release] Ensure that inline {{link-to}} does not cause a crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Mar 1, 2015
1 parent 673e202 commit 4c32905
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/ember-htmlbars/lib/templates/link-to-escaped.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{linkTitle}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{{linkTitle}}}
23 changes: 8 additions & 15 deletions packages/ember-routing-htmlbars/lib/helpers/link-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

import Ember from "ember-metal/core"; // assert
import { LinkView } from "ember-routing-views/views/link";
import { read, isStream } from "ember-metal/streams/utils";
import { isStream } from "ember-metal/streams/utils";
import ControllerMixin from "ember-runtime/mixins/controller";
import inlineEscapedLinkTo from "ember-htmlbars/templates/link-to-escaped";
import inlineUnescapedLinkTo from "ember-htmlbars/templates/link-to-unescaped";

// We need the HTMLBars view helper from ensure ember-htmlbars.
// This ensures it is loaded first:
Expand Down Expand Up @@ -304,22 +306,13 @@ function linkToHelper(params, hash, options, env) {
var linkTitle = params.shift();
var parseTextAsHTML = options.morph.parseTextAsHTML;

if (isStream(linkTitle)) {
hash.linkTitle = { stream: linkTitle };
if (parseTextAsHTML) {
hash.layout = inlineUnescapedLinkTo;
} else {
hash.layout = inlineEscapedLinkTo;
}

options.template = {
isHTMLBars: true,
revision: 'Ember@VERSION_STRING_PLACEHOLDER',
render: function(view, env) {
var value = read(linkTitle) || "";
if (parseTextAsHTML) {
return value;
} else {
return env.dom.createTextNode(value);
}
}
};
hash.linkTitle = linkTitle;
}

for (var i = 0; i < params.length; i++) {
Expand Down
6 changes: 0 additions & 6 deletions packages/ember-routing-views/lib/views/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,8 @@ var LinkView = EmberComponent.extend({
_setupPathObservers: function() {
var params = this.params;

var scheduledRerender = this._wrapAsScheduled(this.rerender);
var scheduledParamsChanged = this._wrapAsScheduled(this._paramsChanged);

if (this.linkTitle) {
var linkTitle = this.linkTitle.stream || this.linkTitle;
subscribe(linkTitle, scheduledRerender, this);
}

for (var i = 0; i < params.length; i++) {
subscribe(params[i], scheduledParamsChanged, this);
}
Expand Down

0 comments on commit 4c32905

Please sign in to comment.