diff --git a/packages/ember-htmlbars/lib/helpers/bind-attr.js b/packages/ember-htmlbars/lib/helpers/bind-attr.js index 821988ed186..708c1807b66 100644 --- a/packages/ember-htmlbars/lib/helpers/bind-attr.js +++ b/packages/ember-htmlbars/lib/helpers/bind-attr.js @@ -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"; @@ -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); diff --git a/packages/ember-htmlbars/lib/helpers/collection.js b/packages/ember-htmlbars/lib/helpers/collection.js index 3eec1facf07..189b283ff06 100644 --- a/packages/ember-htmlbars/lib/helpers/collection.js +++ b/packages/ember-htmlbars/lib/helpers/collection.js @@ -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"; @@ -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; } @@ -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; diff --git a/packages/ember-htmlbars/tests/helpers/bind_attr_test.js b/packages/ember-htmlbars/tests/helpers/bind_attr_test.js index a2b246f41f4..ca1c252109f 100644 --- a/packages/ember-htmlbars/tests/helpers/bind_attr_test.js +++ b/packages/ember-htmlbars/tests/helpers/bind_attr_test.js @@ -672,5 +672,5 @@ QUnit.test('specifying `
` works properl runAppend(view); - deepEqual(warnings, [ ]); + deepEqual(warnings, []); }); diff --git a/packages/ember-htmlbars/tests/helpers/if_unless_test.js b/packages/ember-htmlbars/tests/helpers/if_unless_test.js index c15afcf106e..7b81e6345b8 100644 --- a/packages/ember-htmlbars/tests/helpers/if_unless_test.js +++ b/packages/ember-htmlbars/tests/helpers/if_unless_test.js @@ -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"; @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/packages/ember-routing-views/lib/views/link.js b/packages/ember-routing-views/lib/views/link.js index 6c75cb6e033..fcf240be196 100644 --- a/packages/ember-routing-views/lib/views/link.js +++ b/packages/ember-routing-views/lib/views/link.js @@ -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"; @@ -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; } diff --git a/packages/ember-routing/lib/system/router.js b/packages/ember-routing/lib/system/router.js index a5a0b3b39b2..bd0462fafe6 100644 --- a/packages/ember-routing/lib/system/router.js +++ b/packages/ember-routing/lib/system/router.js @@ -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"; @@ -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); } diff --git a/packages/ember-runtime/lib/mixins/-proxy.js b/packages/ember-runtime/lib/mixins/-proxy.js index cf3495ac34b..232a3b18dc7 100644 --- a/packages/ember-runtime/lib/mixins/-proxy.js +++ b/packages/ember-runtime/lib/mixins/-proxy.js @@ -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." @@ -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); @@ -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); diff --git a/packages/ember-runtime/lib/mixins/copyable.js b/packages/ember-runtime/lib/mixins/copyable.js index e2851f51243..28decc46e0c 100644 --- a/packages/ember-runtime/lib/mixins/copyable.js +++ b/packages/ember-runtime/lib/mixins/copyable.js @@ -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'; @@ -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`); } } }); diff --git a/packages/ember-runtime/lib/system/array_proxy.js b/packages/ember-runtime/lib/system/array_proxy.js index f0d5732fcfb..8a3b53457c1 100644 --- a/packages/ember-runtime/lib/system/array_proxy.js +++ b/packages/ember-runtime/lib/system/array_proxy.js @@ -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"; /** @@ -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, { @@ -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, { diff --git a/packages/ember-runtime/lib/system/set.js b/packages/ember-runtime/lib/system/set.js index 507687539e5..8a171da579c 100644 --- a/packages/ember-runtime/lib/system/set.js +++ b/packages/ember-runtime/lib/system/set.js @@ -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"; @@ -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(',')}>`; } }); diff --git a/packages/ember-runtime/lib/system/string.js b/packages/ember-runtime/lib/system/string.js index 87122528c39..10cbff61f36 100644 --- a/packages/ember-runtime/lib/system/string.js +++ b/packages/ember-runtime/lib/system/string.js @@ -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, diff --git a/packages/ember-runtime/tests/controllers/object_controller_test.js b/packages/ember-runtime/tests/controllers/object_controller_test.js index 01249625a74..979abcc554c 100644 --- a/packages/ember-runtime/tests/controllers/object_controller_test.js +++ b/packages/ember-runtime/tests/controllers/object_controller_test.js @@ -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() { @@ -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() { diff --git a/packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js b/packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js index f882726b2ff..a9f37498f69 100644 --- a/packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js +++ b/packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js @@ -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'; @@ -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`); }); }); @@ -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`); }); @@ -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]}`); } }); diff --git a/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js b/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js index e3ce42db6d5..bef9e2849e4 100644 --- a/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js +++ b/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js @@ -1,5 +1,4 @@ import {get} from 'ember-metal/property_get'; -import EmberStringUtils from 'ember-runtime/system/string'; import EmberObject from 'ember-runtime/system/object'; /* @@ -36,7 +35,7 @@ QUnit.test("concatenates instances", function() { var values = get(obj, 'values'); var expected = ['a', 'b', 'c', 'd', 'e', 'f']; - deepEqual(values, expected, EmberStringUtils.fmt("should concatenate values property (expected: %@, got: %@)", [expected, values])); + deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); QUnit.test("concatenates subclasses", function() { @@ -48,7 +47,7 @@ QUnit.test("concatenates subclasses", function() { var values = get(obj, 'values'); var expected = ['a', 'b', 'c', 'd', 'e', 'f']; - deepEqual(values, expected, EmberStringUtils.fmt("should concatenate values property (expected: %@, got: %@)", [expected, values])); + deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); QUnit.test("concatenates reopen", function() { @@ -60,7 +59,7 @@ QUnit.test("concatenates reopen", function() { var values = get(obj, 'values'); var expected = ['a', 'b', 'c', 'd', 'e', 'f']; - deepEqual(values, expected, EmberStringUtils.fmt("should concatenate values property (expected: %@, got: %@)", [expected, values])); + deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); QUnit.test("concatenates mixin", function() { @@ -75,7 +74,7 @@ QUnit.test("concatenates mixin", function() { var values = get(obj, 'values'); var expected = ['a', 'b', 'c', 'd', 'e', 'f']; - deepEqual(values, expected, EmberStringUtils.fmt("should concatenate values property (expected: %@, got: %@)", [expected, values])); + deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); QUnit.test("concatenates reopen, subclass, and instance", function() { @@ -86,7 +85,7 @@ QUnit.test("concatenates reopen, subclass, and instance", function() { var values = get(obj, 'values'); var expected = ['a', 'b', 'c', 'd', 'e', 'f']; - deepEqual(values, expected, EmberStringUtils.fmt("should concatenate values property (expected: %@, got: %@)", [expected, values])); + deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values}`); }); QUnit.test("concatenates subclasses when the values are functions", function() { @@ -98,8 +97,5 @@ QUnit.test("concatenates subclasses when the values are functions", function() { var values = get(obj, 'functions'); var expected = [K, K]; - deepEqual(values, expected, EmberStringUtils.fmt("should concatenate functions property (expected: %@, got: %@)", [expected, values])); + deepEqual(values, expected, `should concatenate functions property (expected: ${expected}, got: ${values}`); }); - - - diff --git a/packages/ember-runtime/tests/suites/array/indexOf.js b/packages/ember-runtime/tests/suites/array/indexOf.js index d8c7d1a18c6..18d9d3a8026 100644 --- a/packages/ember-runtime/tests/suites/array/indexOf.js +++ b/packages/ember-runtime/tests/suites/array/indexOf.js @@ -1,5 +1,4 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -import {fmt} from "ember-runtime/system/string"; var suite = SuiteModuleBuilder.create(); @@ -12,7 +11,7 @@ suite.test("should return index of object", function() { var idx; for (idx=0;idx