From 4c3290502829d547ee5aba1d9dc236ec741213f5 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Sat, 28 Feb 2015 22:37:26 -0500 Subject: [PATCH] [BUGFIX release] Ensure that inline {{link-to}} does not cause a crash. --- .../lib/templates/link-to-escaped.hbs | 1 + .../lib/templates/link-to-unescaped.hbs | 1 + .../lib/helpers/link-to.js | 23 +++++++------------ .../ember-routing-views/lib/views/link.js | 6 ----- 4 files changed, 10 insertions(+), 21 deletions(-) create mode 100644 packages/ember-htmlbars/lib/templates/link-to-escaped.hbs create mode 100644 packages/ember-htmlbars/lib/templates/link-to-unescaped.hbs diff --git a/packages/ember-htmlbars/lib/templates/link-to-escaped.hbs b/packages/ember-htmlbars/lib/templates/link-to-escaped.hbs new file mode 100644 index 00000000000..4b122366a86 --- /dev/null +++ b/packages/ember-htmlbars/lib/templates/link-to-escaped.hbs @@ -0,0 +1 @@ +{{linkTitle}} \ No newline at end of file diff --git a/packages/ember-htmlbars/lib/templates/link-to-unescaped.hbs b/packages/ember-htmlbars/lib/templates/link-to-unescaped.hbs new file mode 100644 index 00000000000..5cb318cf43c --- /dev/null +++ b/packages/ember-htmlbars/lib/templates/link-to-unescaped.hbs @@ -0,0 +1 @@ +{{{linkTitle}}} \ No newline at end of file diff --git a/packages/ember-routing-htmlbars/lib/helpers/link-to.js b/packages/ember-routing-htmlbars/lib/helpers/link-to.js index 6085e1b9e46..411d8d1cb47 100644 --- a/packages/ember-routing-htmlbars/lib/helpers/link-to.js +++ b/packages/ember-routing-htmlbars/lib/helpers/link-to.js @@ -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: @@ -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++) { diff --git a/packages/ember-routing-views/lib/views/link.js b/packages/ember-routing-views/lib/views/link.js index 953d9238f43..d9ab390b8ba 100644 --- a/packages/ember-routing-views/lib/views/link.js +++ b/packages/ember-routing-views/lib/views/link.js @@ -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); }