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 use of Em.String.fmt & mark as deprecated #11959

Merged
merged 1 commit into from
Aug 3, 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
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 @@ -10,7 +10,6 @@ import compile from 'ember-template-compiler/system/compile';
import ArrayProxy from 'ember-runtime/system/array_proxy';

import { set } from 'ember-metal/property_set';
import { fmt } from 'ember-runtime/system/string';
import { typeOf } from 'ember-runtime/utils';
import { runAppend, runDestroy } from 'ember-runtime/tests/utils';

Expand Down Expand Up @@ -279,7 +278,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 "${val}"; ${typeOf(val)}`);
run(function() {
set(view, 'onDrugs', true);
});
Expand Down Expand Up @@ -333,7 +332,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 "${val}"`);

run(function() {
set(view, 'inception', true);
Expand Down Expand Up @@ -368,7 +367,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 ${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 "${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 "${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 ${val}`);

run(function() {
set(view, 'inception', true);
Expand Down
8 changes: 1 addition & 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 { defineProperty } from 'ember-metal/properties';
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 @@ -546,12 +545,7 @@ 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.scopedPropertyName, qps[1] ? qps[1].qp.scopedPropertyName : '', 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.scopedPropertyName}\` and \`${qps[1] ? qps[1].qp.scopedPropertyName : ''}\` 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
12 changes: 3 additions & 9 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 @@ -75,9 +74,7 @@ export default Mixin.create({
unknownProperty(key) {
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]),
Ember.deprecate(`You attempted to access \`${key}\` from \`${this}\`, but object proxying is deprecated. Please use \`model.${key}\` instead.`,
!this.isController,
{ id: 'ember-runtime.controller-proxy', until: '3.0.0' }
);
Expand All @@ -95,12 +92,9 @@ 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]),
Ember.deprecate(`You attempted to set \`${key}\` from \`${this}\`, but object proxying is deprecated. Please use \`model.${key}\` instead.`,
!this.isController,
{ id: 'ember-runtime.controller-proxy', until: '3.0.0' }
);
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 Ember from 'ember-metal/core';
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 @@ -63,7 +62,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`);
}
}
});
8 changes: 2 additions & 6 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 @@ -191,9 +190,7 @@ 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]),
isArray(content) || content.isDestroyed);
Ember.assert(`ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ${typeof content}`, isArray(content) || content.isDestroyed);

content.addArrayObserver(this, {
willChange: 'contentArrayWillChange',
Expand Down Expand Up @@ -228,8 +225,7 @@ 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
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 @@ -160,6 +160,7 @@ export default {
@param {Array} formats An array of parameters to interpolate into string.
@return {String} formatted string
@public
@deprecated Use ES6 template strings instead: https://babeljs.io/docs/learn-es6/#template-strings');
*/
fmt,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { get } from 'ember-metal/property_get';
import { computed } from 'ember-metal/computed';
import run from 'ember-metal/run_loop';
import { observer } from 'ember-metal/mixin';
import { fmt, w } from 'ember-runtime/system/string';
import { w } from 'ember-runtime/system/string';
import EmberObject from 'ember-runtime/system/object';
import Observable from 'ember-runtime/mixins/observable';

Expand Down Expand Up @@ -376,17 +376,17 @@ QUnit.test('getting values should call function return value', function() {
var keys = w('computed computedCached dependent dependentFront dependentCached');

keys.forEach(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
w('computedCalls dependentFrontCalls dependentCalls').forEach((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 2x`);
});

w('computedCachedCalls dependentCachedCalls').forEach((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 1x`);
});
});

Expand All @@ -396,11 +396,11 @@ QUnit.test('setting values should call function return value', function() {
var values = w('value1 value2');

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

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

equal(object.set(key, values[1]), values[1], 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]), values[1], `Try #3: object.set(${key}, ${values[1]}) should not run function since it is setting same value as before`);
});

// verify each call count. cached should only be called once
Expand All @@ -411,9 +411,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
Original file line number Diff line number Diff line change
@@ -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';

/*
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -98,7 +97,7 @@ 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})`);
});


Expand Down
3 changes: 1 addition & 2 deletions packages/ember-runtime/tests/suites/array/indexOf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite';
import {fmt} from 'ember-runtime/system/string';

var suite = SuiteModuleBuilder.create();

Expand All @@ -12,7 +11,7 @@ suite.test('should return index of object', function() {
var idx;

for (idx = 0;idx < len;idx++) {
equal(obj.indexOf(expected[idx]), idx, fmt('obj.indexOf(%@) should match idx', [expected[idx]]));
equal(obj.indexOf(expected[idx]), idx, `obj.indexOf(${expected[idx]}) should match idx`);
}
});

Expand Down
10 changes: 3 additions & 7 deletions packages/ember-runtime/tests/suites/array/lastIndexOf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite';
import {fmt} from 'ember-runtime/system/string';

var suite = SuiteModuleBuilder.create();

Expand All @@ -12,8 +11,7 @@ suite.test('should return index of object\'s last occurrence', function() {
var idx;

for (idx = 0;idx < len;idx++) {
equal(obj.lastIndexOf(expected[idx]), idx,
fmt('obj.lastIndexOf(%@) should match idx', [expected[idx]]));
equal(obj.lastIndexOf(expected[idx]), idx, `obj.lastIndexOf(${expected[idx]}) should match idx`);
}
});

Expand All @@ -24,8 +22,7 @@ suite.test('should return index of object\'s last occurrence even startAt search
var idx;

for (idx = 0;idx < len;idx++) {
equal(obj.lastIndexOf(expected[idx], len), idx,
fmt('obj.lastIndexOfs(%@) should match idx', [expected[idx]]));
equal(obj.lastIndexOf(expected[idx], len), idx, `obj.lastIndexOfs(${expected[idx]}) should match idx`);
}
});

Expand All @@ -36,8 +33,7 @@ suite.test('should return index of object\'s last occurrence even startAt search
var idx;

for (idx = 0;idx < len;idx++) {
equal(obj.lastIndexOf(expected[idx], len + 1), idx,
fmt('obj.lastIndexOf(%@) should match idx', [expected[idx]]));
equal(obj.lastIndexOf(expected[idx], len + 1), idx, `obj.lastIndexOf(${expected[idx]}) should match idx`);
}
});

Expand Down
3 changes: 1 addition & 2 deletions packages/ember-runtime/tests/suites/array/objectAt.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite';
import {fmt} from 'ember-runtime/system/string';

var suite = SuiteModuleBuilder.create();

Expand All @@ -12,7 +11,7 @@ suite.test('should return object at specified index', function() {
var idx;

for (idx = 0;idx < len;idx++) {
equal(obj.objectAt(idx), expected[idx], fmt('obj.objectAt(%@) should match', [idx]));
equal(obj.objectAt(idx), expected[idx], `obj.objectAt(${idx}) should match`);
}
});

Expand Down
3 changes: 1 addition & 2 deletions packages/ember-views/lib/streams/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Ember from 'ember-metal/core';
import { get } from 'ember-metal/property_get';
import { fmt } from 'ember-runtime/system/string';
import { read, isStream } from 'ember-metal/streams/utils';
import ControllerMixin from 'ember-runtime/mixins/controller';

Expand All @@ -15,7 +14,7 @@ export function readViewFactory(object, container) {
viewClass = value;
}

Ember.assert(fmt(value + ' must be a subclass or an instance of Ember.View, not %@', [viewClass]), (function(viewClass) {
Ember.assert(`${value} must be a subclass or an instance of Ember.View, not ${viewClass}`, (function(viewClass) {
return viewClass && (viewClass.isViewFactory || viewClass.isView || viewClass.isComponentFactory || viewClass.isComponent);
})(viewClass));

Expand Down
3 changes: 1 addition & 2 deletions packages/ember-views/lib/system/event_dispatcher.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 isNone from 'ember-metal/is_none';
import run from 'ember-metal/run_loop';
import { fmt } from 'ember-runtime/system/string';
import EmberObject from 'ember-runtime/system/object';
import jQuery from 'ember-views/system/jquery';
import ActionManager from 'ember-views/system/action_manager';
Expand Down Expand Up @@ -140,7 +139,7 @@ export default EmberObject.extend({

rootElement = jQuery(get(this, 'rootElement'));

Ember.assert(fmt('You cannot use the same root element (%@) multiple times in an Ember.Application', [rootElement.selector || rootElement[0].tagName]), !rootElement.is('.ember-application'));
Ember.assert(`You cannot use the same root element (${rootElement.selector || rootElement[0].tagName}) multiple times in an Ember.Application`, !rootElement.is('.ember-application'));
Ember.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest('.ember-application').length);
Ember.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find('.ember-application').length);

Expand Down
Loading