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 beta] remove internal uses of Ember.String.fmt #10861

Closed
Closed
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
5 changes: 2 additions & 3 deletions packages/ember-htmlbars/lib/helpers/bind-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import Ember from "ember-metal/core"; // Ember.assert

import { fmt } from "ember-runtime/system/string";
import AttrNode from "ember-views/attr_nodes/attr_node";
import LegacyBindAttrNode from "ember-views/attr_nodes/legacy_bind";
import keys from "ember-metal/keys";
Expand Down Expand Up @@ -181,8 +180,8 @@ function bindAttrHelper(params, hash, options, env) {
lazyValue = path;
} else {
Ember.assert(
fmt("You must provide an expression as the value of bound attribute." +
" You specified: %@=%@", [attr, path]),
"You must provide an expression as the value of bound attribute." +
` You specified: ${attr}=${path}`,
typeof path === 'string'
);
lazyValue = view.getStream(path);
Expand Down
5 changes: 2 additions & 3 deletions packages/ember-htmlbars/lib/helpers/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import Ember from "ember-metal/core"; // Ember.assert, Ember.deprecate
import { IS_BINDING } from "ember-metal/mixin";
import { fmt } from "ember-runtime/system/string";
import { get } from "ember-metal/property_get";
import CollectionView from "ember-views/views/collection_view";
import { readViewFactory } from "ember-views/streams/utils";
Expand Down Expand Up @@ -161,7 +160,7 @@ export function collectionHelper(params, hash, options, env) {
var collectionClass;
if (path) {
collectionClass = readViewFactory(path, container);
Ember.assert(fmt("%@ #collection: Could not find collection class %@", [data.view, path]), !!collectionClass);
Ember.assert(`${data.view} #collection: Could not find collection class ${path}`, !!collectionClass);
} else {
collectionClass = CollectionView;
}
Expand All @@ -185,7 +184,7 @@ export function collectionHelper(params, hash, options, env) {
itemViewClass = container.lookupFactory('view:'+itemViewClass);
}

Ember.assert(fmt("%@ #collection: Could not find itemViewClass %@", [data.view, itemViewClass]), !!itemViewClass);
Ember.assert(`${data.view} #collection: Could not find itemViewClass ${itemViewClass}`, !!itemViewClass);

delete hash.itemViewClass;
delete hash.itemView;
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-htmlbars/tests/helpers/bind_attr_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,5 +672,5 @@ QUnit.test('specifying `<div {{bind-attr style=userValue}}></div>` works properl

runAppend(view);

deepEqual(warnings, [ ]);
deepEqual(warnings, []);
});
13 changes: 6 additions & 7 deletions packages/ember-htmlbars/tests/helpers/if_unless_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import _MetamorphView from 'ember-views/views/metamorph_view';
import compile from "ember-template-compiler/system/compile";

import { set } from 'ember-metal/property_set';
import { fmt } from 'ember-runtime/system/string';
import { typeOf } from 'ember-metal/utils';
import { forEach } from 'ember-metal/enumerable_utils';
import { runAppend, runDestroy } from "ember-runtime/tests/utils";
Expand Down Expand Up @@ -281,7 +280,7 @@ QUnit.test('should update the block when object passed to #unless helper changes
set(view, 'onDrugs', val);
});

equal(view.$('h1').text(), 'Eat your vegetables', fmt('renders block when conditional is "%@"; %@', [String(val), typeOf(val)]));
equal(view.$('h1').text(), 'Eat your vegetables', `renders block when conditional is "${String(val)}"; ${typeOf(val)}`);

run(function() {
set(view, 'onDrugs', true);
Expand Down Expand Up @@ -336,7 +335,7 @@ QUnit.test('should update the block when object passed to #if helper changes', f
set(view, 'inception', val);
});

equal(view.$('h1').text(), '', fmt('hides block when conditional is "%@"', [String(val)]));
equal(view.$('h1').text(), '', `hides block when conditional is "${String(val)}"`);

run(function() {
set(view, 'inception', true);
Expand Down Expand Up @@ -371,7 +370,7 @@ QUnit.test('should update the block when object passed to #if helper changes and
set(view, 'inception', val);
});

equal(view.$('h1').text(), 'BOONG?', fmt('renders alternate if %@', [String(val)]));
equal(view.$('h1').text(), 'BOONG?', `renders alternate if ${String(val)}`);

run(function() {
set(view, 'inception', true);
Expand Down Expand Up @@ -444,7 +443,7 @@ QUnit.test('should update the block when object passed to #unless helper changes
set(view, 'onDrugs', val);
});

equal(view.$('h1').text(), 'Eat your vegetables', fmt('renders block when conditional is "%@"; %@', [String(val), typeOf(val)]));
equal(view.$('h1').text(), 'Eat your vegetables', `renders block when conditional is "${String(val)}"; ${typeOf(val)}`);

run(function() {
set(view, 'onDrugs', true);
Expand Down Expand Up @@ -499,7 +498,7 @@ QUnit.test('should update the block when object passed to #if helper changes', f
set(view, 'inception', val);
});

equal(view.$('h1').text(), '', fmt('hides block when conditional is "%@"', [String(val)]));
equal(view.$('h1').text(), '', `hides block when conditional is "${String(val)}"`);

run(function() {
set(view, 'inception', true);
Expand Down Expand Up @@ -534,7 +533,7 @@ QUnit.test('should update the block when object passed to #if helper changes and
set(view, 'inception', val);
});

equal(view.$('h1').text(), 'BOONG?', fmt('renders alternate if %@', [String(val)]));
equal(view.$('h1').text(), 'BOONG?', `renders alternate if ${String(val)}`);

run(function() {
set(view, 'inception', true);
Expand Down
8 changes: 3 additions & 5 deletions packages/ember-routing-views/lib/views/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { get } from "ember-metal/property_get";
import merge from "ember-metal/merge";
import run from "ember-metal/run_loop";
import { computed } from "ember-metal/computed";
import { fmt } from "ember-runtime/system/string";
import keys from "ember-metal/keys";
import { isSimpleClick } from "ember-views/system/utils";
import EmberComponent from "ember-views/views/component";
Expand Down Expand Up @@ -499,10 +498,9 @@ var LinkView = EmberComponent.extend({

if (!namedRoute) { return; }

Ember.assert(fmt("The attempt to link-to route '%@' failed. " +
"The router did not find '%@' in its possible routes: '%@'",
[namedRoute, namedRoute, keys(router.router.recognizer.names).join("', '")]),
router.hasRoute(namedRoute));
Ember.assert(`The attempt to link-to route '${namedRoute}' failed. ` +
`The router did not find '${namedRoute}' in its possible routes: '${keys(router.router.recognizer.names).join("', '")}'`,
router.hasRoute(namedRoute));

if (!paramsAreLoaded(resolvedParams.models)) { return; }

Expand Down
15 changes: 8 additions & 7 deletions packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { computed } from "ember-metal/computed";
import merge from "ember-metal/merge";
import run from "ember-metal/run_loop";

import { fmt } from "ember-runtime/system/string";
import EmberObject from "ember-runtime/system/object";
import Evented from "ember-runtime/mixins/evented";
import EmberRouterDSL from "ember-routing/system/dsl";
Expand Down Expand Up @@ -498,12 +497,14 @@ var EmberRouter = EmberObject.extend(Evented, {

for (var key in groupedByUrlKey) {
var qps = groupedByUrlKey[key];
Ember.assert(fmt("You're not allowed to have more than one controller " +
"property map to the same query param key, but both " +
"`%@` and `%@` map to `%@`. You can fix this by mapping " +
"one of the controller properties to a different query " +
"param key via the `as` config option, e.g. `%@: { as: 'other-%@' }`",
[qps[0].qp.fprop, qps[1] ? qps[1].qp.fprop : "", qps[0].qp.urlKey, qps[0].qp.prop, qps[0].qp.prop]), qps.length <= 1);
Ember.assert("You're not allowed to have more than one controller " +
"property map to the same query param key, but both " +
`"${qps[0].qp.fprop}" and "${qps[1] ? qps[1].qp.fprop : ""}" ` +
`map to "${qps[0].qp.urlKey}". You can fix this by mapping ` +
"one of the controller properties to a different query " +
'param key via the "as" config option, e.g. ' +
`"${qps[0].qp.prop}: { as: 'other-${qps[0].qp.prop}' }"`,
qps.length <= 1);
var qp = qps[0].qp;
queryParams[qp.urlKey] = qp.route.serializeQueryParam(qps[0].value, qp.urlKey, qp.type);
}
Expand Down
13 changes: 6 additions & 7 deletions packages/ember-runtime/lib/mixins/-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
import { computed } from "ember-metal/computed";
import { defineProperty } from "ember-metal/properties";
import { Mixin, observer } from "ember-metal/mixin";
import { fmt } from "ember-runtime/system/string";

function contentPropertyWillChange(content, contentKey) {
var key = contentKey.slice(8); // remove "content."
Expand Down Expand Up @@ -74,8 +73,8 @@ export default Mixin.create({
var content = get(this, 'content');
if (content) {
Ember.deprecate(
fmt('You attempted to access `%@` from `%@`, but object proxying is deprecated. ' +
'Please use `model.%@` instead.', [key, this, key]),
`You attempted to access "${key}" from "${this}", but object proxying is deprecated. ` +
`Please use "model.${key}" instead.`,
!this.isController
);
return get(content, key);
Expand All @@ -92,12 +91,12 @@ export default Mixin.create({
}

var content = get(this, 'content');
Ember.assert(fmt("Cannot delegate set('%@', %@) to the 'content' property of" +
" object proxy %@: its 'content' is undefined.", [key, value, this]), content);
Ember.assert(`Cannot delegate set("${key}", ${value}) to the "content" property of` +
` object proxy ${this}: its "content" is undefined.`, content);

Ember.deprecate(
fmt('You attempted to set `%@` from `%@`, but object proxying is deprecated. ' +
'Please use `model.%@` instead.', [key, this, key]),
`You attempted to set "${key}" from "${this}", but object proxying is deprecated. ` +
`Please use "model.${key}" instead.`,
!this.isController
);
return set(content, key, value);
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-runtime/lib/mixins/copyable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { get } from "ember-metal/property_get";
import { Mixin } from "ember-metal/mixin";
import { Freezable } from "ember-runtime/mixins/freezable";
import { fmt } from "ember-runtime/system/string";
import EmberError from 'ember-metal/error';


Expand Down Expand Up @@ -57,7 +56,7 @@ export default Mixin.create({
if (Freezable && Freezable.detect(this)) {
return get(this, 'isFrozen') ? this : this.copy().freeze();
} else {
throw new EmberError(fmt("%@ does not support freezing", [this]));
throw new EmberError(`${this} does not support freezing`);
}
}
});
9 changes: 4 additions & 5 deletions packages/ember-runtime/lib/system/array_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import EmberError from "ember-metal/error";
import EmberObject from "ember-runtime/system/object";
import MutableArray from "ember-runtime/mixins/mutable_array";
import Enumerable from "ember-runtime/mixins/enumerable";
import { fmt } from "ember-runtime/system/string";
import alias from "ember-metal/alias";

/**
Expand Down Expand Up @@ -185,8 +184,8 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
var content = get(this, 'content');

if (content) {
Ember.assert(fmt('ArrayProxy expects an Array or ' +
'Ember.ArrayProxy, but you passed %@', [typeof content]),
Ember.assert('ArrayProxy expects an Array or ' +
`Ember.ArrayProxy, but you passed ${typeof content}`,
isArray(content) || content.isDestroyed);

content.addArrayObserver(this, {
Expand Down Expand Up @@ -222,8 +221,8 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
var arrangedContent = get(this, 'arrangedContent');

if (arrangedContent) {
Ember.assert(fmt('ArrayProxy expects an Array or ' +
'Ember.ArrayProxy, but you passed %@', [typeof arrangedContent]),
Ember.assert('ArrayProxy expects an Array or ' +
`Ember.ArrayProxy, but you passed ${typeof arrangedContent}`,
isArray(arrangedContent) || arrangedContent.isDestroyed);

arrangedContent.addArrayObserver(this, {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-runtime/lib/system/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { get } from "ember-metal/property_get";
import { set } from "ember-metal/property_set";
import { guidFor } from "ember-metal/utils";
import isNone from 'ember-metal/is_none';
import { fmt } from "ember-runtime/system/string";
import CoreObject from "ember-runtime/system/core_object";
import MutableEnumerable from "ember-runtime/mixins/mutable_enumerable";
import Enumerable from "ember-runtime/mixins/enumerable";
Expand Down Expand Up @@ -496,6 +495,6 @@ export default CoreObject.extend(MutableEnumerable, Copyable, Freezable, {
for (idx = 0; idx < len; idx++) {
array[idx] = this[idx];
}
return fmt("Ember.Set<%@>", [array.join(',')]);
return `Ember.Set<${array.join(',')}>`;
}
});
1 change: 1 addition & 0 deletions packages/ember-runtime/lib/system/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default {
@param {String} str The string to format
@param {Array} formats An array of parameters to interpolate into string.
@return {String} formatted string
@deprecated Use ES6 template strings instead: https://babeljs.io/docs/learn-es6/#template-strings');
*/
fmt: fmt,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ QUnit.test('accessing model properties via proxy behavior results in a deprecati

expectDeprecation(function() {
controller.get('bar');
}, /object proxying is deprecated\. Please use `model\.bar` instead\./);
}, /object proxying is deprecated\. Please use "model\.bar" instead\./);
});

QUnit.test('setting model properties via proxy behavior results in a deprecation [DEPRECATED]', function() {
Expand All @@ -58,7 +58,7 @@ QUnit.test('setting model properties via proxy behavior results in a deprecation

expectDeprecation(function() {
controller.set('bar', 'derp');
}, /object proxying is deprecated\. Please use `model\.bar` instead\./);
}, /object proxying is deprecated\. Please use "model\.bar" instead\./);
});

QUnit.test('auto-generated controllers are not deprecated', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import run from 'ember-metal/run_loop';
import { typeOf } from 'ember-metal/utils';
import { observer } from 'ember-metal/mixin';
import {
fmt,
w
} from "ember-runtime/system/string";
import EmberObject from 'ember-runtime/system/object';
Expand Down Expand Up @@ -431,17 +430,17 @@ QUnit.test("getting values should call function return value", function() {
var keys = w('computed computedCached dependent dependentFront dependentCached');

forEach(keys, function(key) {
equal(object.get(key), key, fmt('Try #1: object.get(%@) should run function', [key]));
equal(object.get(key), key, fmt('Try #2: object.get(%@) should run function', [key]));
equal(object.get(key), key, `Try #1: object.get(${key}) should run function`);
equal(object.get(key), key, `Try #2: object.get(${key}) should run function`);
});

// verify each call count. cached should only be called once
forEach(w('computedCalls dependentFrontCalls dependentCalls'), function(key) {
equal(object[key].length, 2, fmt('non-cached property %@ should be called 2x', [key]));
equal(object[key].length, 2, `non-cached property ${key} should be called`);
});

forEach(w('computedCachedCalls dependentCachedCalls'), function(key) {
equal(object[key].length, 1, fmt('non-cached property %@ should be called 1x', [key]));
equal(object[key].length, 1, `non-cached property ${key} should be called`);
});

});
Expand All @@ -454,11 +453,11 @@ QUnit.test("setting values should call function return value", function() {

forEach(keys, function(key) {

equal(object.set(key, values[0]), object, fmt('Try #1: object.set(%@, %@) should run function', [key, values[0]]));
equal(object.set(key, values[0]), object, `Try #1: object.set(${key}, ${values[0]}) should run function`);

equal(object.set(key, values[1]), object, fmt('Try #2: object.set(%@, %@) should run function', [key, values[1]]));
equal(object.set(key, values[1]), object, `Try #2: object.set(${key}, ${values[1]}) should run function`);

equal(object.set(key, values[1]), object, fmt('Try #3: object.set(%@, %@) should not run function since it is setting same value as before', [key, values[1]]));
equal(object.set(key, values[1]), object, `Try #3: object.set(${key}, ${values[1]}) should not run function since it is setting same value as before`);

});

Expand All @@ -471,9 +470,9 @@ QUnit.test("setting values should call function return value", function() {
// Cached properties first check their cached value before setting the
// property. Other properties blindly call set.
expectedLength = 3;
equal(calls.length, expectedLength, fmt('set(%@) should be called the right amount of times', [key]));
equal(calls.length, expectedLength, `set(${key}) should be called the right amount of times`);
for (idx=0;idx<2;idx++) {
equal(calls[idx], values[idx], fmt('call #%@ to set(%@) should have passed value %@', [idx+1, key, values[idx]]));
equal(calls[idx], values[idx], `call #${idx+1} to set(${key}) should have passed value ${values[idx]}`);
}
});

Expand Down
Loading