Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] Ensure that inline {{link-to}} does not cause a crash. #10553

Merged
merged 1 commit into from
Mar 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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