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

[CLEANUP Beta] Drop Object.create polyfill – just use Object.create [E… #11460

Merged
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
7 changes: 3 additions & 4 deletions packages/ember-application/lib/system/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { set } from "ember-metal/property_set";
import { runLoadHooks } from "ember-runtime/system/lazy_load";
import Namespace from "ember-runtime/system/namespace";
import DefaultResolver from "ember-application/system/resolver";
import create from "ember-metal/platform/create";
import run from "ember-metal/run_loop";
import { canInvoke } from "ember-metal/utils";
import Controller from "ember-runtime/controllers/controller";
Expand Down Expand Up @@ -846,8 +845,8 @@ if (isEnabled('ember-application-visit')) {
}

Application.reopenClass({
initializers: create(null),
instanceInitializers: create(null),
initializers: Object.create(null),
instanceInitializers: Object.create(null),

/**
Initializer receives an object which has the following attributes:
Expand Down Expand Up @@ -1174,7 +1173,7 @@ function buildInitializerMethod(bucketName, humanName) {
// pollute the parent class as well as other subclasses.
if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) {
var attrs = {};
attrs[bucketName] = create(this[bucketName]);
attrs[bucketName] = Object.create(this[bucketName]);
this.reopenClass(attrs);
}

Expand Down
4 changes: 1 addition & 3 deletions packages/ember-htmlbars/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
@submodule ember-htmlbars
*/

import o_create from "ember-metal/platform/create";

/**
@private
@property helpers
*/
var helpers = o_create(null);
var helpers = Object.create(null);

/**
@module ember
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
*/

import { hooks } from "htmlbars-runtime";
import o_create from "ember-metal/platform/create";

/**
@private
@property helpers
*/
var keywords = o_create(hooks.keywords);
var keywords = Object.create(hooks.keywords);

/**
@module ember
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/keywords/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import isEnabled from "ember-metal/features";
import Stream from "ember-metal/streams/stream";
import { labelFor } from "ember-metal/streams/utils";
import { read, isStream } from "ember-metal/streams/utils";
import create from "ember-metal/platform/create";
import merge from "ember-metal/merge";

if (isEnabled('ember-htmlbars-get-helper')) {
Expand Down Expand Up @@ -41,7 +40,7 @@ if (isEnabled('ember-htmlbars-get-helper')) {
this.addDependency(obj);
};

GetStream.prototype = create(Stream.prototype);
GetStream.prototype = Object.create(Stream.prototype);

merge(GetStream.prototype, {
updateValueDependency() {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/keywords/mut.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import create from "ember-metal/platform/create";
import merge from "ember-metal/merge";
import { symbol } from "ember-metal/utils";
import ProxyStream from "ember-metal/streams/proxy-stream";
Expand Down Expand Up @@ -57,7 +56,7 @@ function MutStream(stream) {
this[MUTABLE_REFERENCE] = true;
}

MutStream.prototype = create(ProxyStream.prototype);
MutStream.prototype = Object.create(ProxyStream.prototype);

merge(MutStream.prototype, {
cell() {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/keywords/unbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default function unbound(morph, env, scope, originalParams, hash, templat
}

import merge from "ember-metal/merge";
import create from "ember-metal/platform/create";
import Stream from "ember-metal/streams/stream";
import { read } from "ember-metal/streams/utils";

Expand All @@ -42,7 +41,7 @@ function VolatileStream(source) {
this.addDependency(source);
}

VolatileStream.prototype = create(Stream.prototype);
VolatileStream.prototype = Object.create(Stream.prototype);

merge(VolatileStream.prototype, {
value() {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/morphs/attr-morph.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Ember from "ember-metal/core";
import DOMHelper from "dom-helper";
import o_create from 'ember-metal/platform/create';

var HTMLBarsAttrMorph = DOMHelper.prototype.AttrMorphClass;

Expand All @@ -16,7 +15,7 @@ function EmberAttrMorph(element, attrName, domHelper, namespace) {
this.streamUnsubscribers = null;
}

var proto = EmberAttrMorph.prototype = o_create(HTMLBarsAttrMorph.prototype);
var proto = EmberAttrMorph.prototype = Object.create(HTMLBarsAttrMorph.prototype);
proto.HTMLBarsAttrMorph$setContent = HTMLBarsAttrMorph.prototype.setContent;

proto._deprecateEscapedStyle = function EmberAttrMorph_deprecateEscapedStyle(value) {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/morphs/morph.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import DOMHelper from "dom-helper";
import o_create from 'ember-metal/platform/create';

var HTMLBarsMorph = DOMHelper.prototype.MorphClass;
let guid = 1;
Expand All @@ -22,7 +21,7 @@ function EmberMorph(DOMHelper, contextualElement) {
this.shouldReceiveAttrs = false;
}

var proto = EmberMorph.prototype = o_create(HTMLBarsMorph.prototype);
var proto = EmberMorph.prototype = Object.create(HTMLBarsMorph.prototype);
proto.HTMLBarsMorph$constructor = HTMLBarsMorph;
proto.HTMLBarsMorph$clear = HTMLBarsMorph.prototype.clear;

Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/streams/built-in-helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Stream from "ember-metal/streams/stream";
import create from "ember-metal/platform/create";
import merge from "ember-metal/merge";
import {
getArrayValues,
Expand All @@ -17,7 +16,7 @@ export default function BuiltInHelperStream(helper, params, hash, templates, env
this.context = context;
}

BuiltInHelperStream.prototype = create(Stream.prototype);
BuiltInHelperStream.prototype = Object.create(Stream.prototype);

merge(BuiltInHelperStream.prototype, {
compute() {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/streams/compat-helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Stream from "ember-metal/streams/stream";
import create from "ember-metal/platform/create";
import merge from "ember-metal/merge";

export default function CompatHelperStream(helper, params, hash, templates, env, scope, label) {
Expand All @@ -12,7 +11,7 @@ export default function CompatHelperStream(helper, params, hash, templates, env,
this.hash = hash;
}

CompatHelperStream.prototype = create(Stream.prototype);
CompatHelperStream.prototype = Object.create(Stream.prototype);

merge(CompatHelperStream.prototype, {
compute() {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/streams/helper-factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Stream from "ember-metal/streams/stream";
import create from "ember-metal/platform/create";
import merge from "ember-metal/merge";
import {
getArrayValues,
Expand All @@ -15,7 +14,7 @@ export default function HelperFactoryStream(helperFactory, params, hash, label)
this.helper = null;
}

HelperFactoryStream.prototype = create(Stream.prototype);
HelperFactoryStream.prototype = Object.create(Stream.prototype);

merge(HelperFactoryStream.prototype, {
compute() {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/streams/helper-instance.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Stream from "ember-metal/streams/stream";
import create from "ember-metal/platform/create";
import merge from "ember-metal/merge";
import {
getArrayValues,
Expand All @@ -14,7 +13,7 @@ export default function HelperInstanceStream(helper, params, hash, label) {
this.linkable = true;
}

HelperInstanceStream.prototype = create(Stream.prototype);
HelperInstanceStream.prototype = Object.create(Stream.prototype);

merge(HelperInstanceStream.prototype, {
compute() {
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/lib/system/dom-helper.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import DOMHelper from "dom-helper";
import EmberMorph from "ember-htmlbars/morphs/morph";
import EmberAttrMorph from "ember-htmlbars/morphs/attr-morph";
import o_create from 'ember-metal/platform/create';

function EmberDOMHelper(_document) {
DOMHelper.call(this, _document);
}

var proto = EmberDOMHelper.prototype = o_create(DOMHelper.prototype);
var proto = EmberDOMHelper.prototype = Object.create(DOMHelper.prototype);
proto.MorphClass = EmberMorph;
proto.AttrMorphClass = EmberAttrMorph;

Expand Down
3 changes: 1 addition & 2 deletions packages/ember-htmlbars/tests/helpers/each_in_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import isEnabled from "ember-metal/features";
import Component from "ember-views/views/component";
import compile from "ember-template-compiler/system/compile";
import run from "ember-metal/run_loop";
import create from "ember-metal/platform/create";

import { runAppend, runDestroy } from "ember-runtime/tests/utils";

Expand Down Expand Up @@ -88,7 +87,7 @@ if (isEnabled('ember-htmlbars-each-in')) {
"JavaScript Frameworks": Infinity
};

let categories = create(protoCategories);
let categories = Object.create(protoCategories);
categories["Televisions"] = 183;
categories["Alarm Clocks"] = 999;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import EmberView from 'ember-views/views/view';
import compile from 'ember-template-compiler/system/compile';

import { set } from 'ember-metal/property_set';
import o_create from 'ember-metal/platform/create';
import { runAppend, runDestroy } from "ember-runtime/tests/utils";

var view;
Expand Down Expand Up @@ -64,7 +63,7 @@ QUnit.test('should read an escaped number value', function() {

QUnit.test('should read from an Object.create(null)', function() {
// Use ember's polyfill for Object.create
var nullObject = o_create(null);
var nullObject = Object.create(null);
nullObject['foo'] = 'bar';
view = EmberView.create({
context: { nullObject: nullObject },
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-metal/lib/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
defineProperty
} from "ember-metal/properties";
import { ComputedProperty } from "ember-metal/computed";
import create from "ember-metal/platform/create";
import {
meta,
inspect
Expand All @@ -27,7 +26,7 @@ export function AliasedProperty(altKey) {
this._dependentKeys = [altKey];
}

AliasedProperty.prototype = create(Descriptor.prototype);
AliasedProperty.prototype = Object.create(Descriptor.prototype);

AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) {
return get(obj, this.altKey);
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-metal/lib/dependent_keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//
"REMOVE_USE_STRICT: true";

import o_create from "ember-metal/platform/create";
import {
watch,
unwatch
Expand Down Expand Up @@ -38,7 +37,7 @@ function keysForDep(depsMeta, depKey) {
} else if (!depsMeta.hasOwnProperty(depKey)) {
// otherwise if the dependency list is inherited from
// a superclass, clone the hash
keys = depsMeta[depKey] = o_create(keys);
keys = depsMeta[depKey] = Object.create(keys);
}
return keys;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-metal/lib/dictionary.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import create from "ember-metal/platform/create";

// the delete is meant to hint at runtimes that this object should remain in
// dictionary mode. This is clearly a runtime specific hack, but currently it
// appears worthwhile in some usecases. Please note, these deletes do increase
// the cost of creation dramatically over a plain Object.create. And as this
// only makes sense for long-lived dictionaries that aren't instantiated often.
export default function makeDictionary(parent) {
var dict = create(parent);
var dict = Object.create(parent);
dict['_dict'] = null;
delete dict['_dict'];
return dict;
Expand Down
8 changes: 2 additions & 6 deletions packages/ember-metal/lib/error.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import create from "ember-metal/platform/create";

var errorProps = [
'description',
'fileName',
Expand All @@ -19,7 +17,7 @@ var errorProps = [
@constructor
@public
*/
function EmberError() {
export default function EmberError() {
var tmp = Error.apply(this, arguments);

// Adds a `stack` property to the given error object that will yield the
Expand All @@ -38,6 +36,4 @@ function EmberError() {
}
}

EmberError.prototype = create(Error.prototype);

export default EmberError;
EmberError.prototype = Object.create(Error.prototype);
5 changes: 2 additions & 3 deletions packages/ember-metal/lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
apply,
applyStr
} from "ember-metal/utils";
import create from "ember-metal/platform/create";

/* listener flags */
var ONCE = 1;
Expand Down Expand Up @@ -59,11 +58,11 @@ function actionsFor(obj, eventName) {
var listeners = meta.listeners;

if (!listeners) {
listeners = meta.listeners = create(null);
listeners = meta.listeners = Object.create(null);
listeners.__source__ = obj;
} else if (listeners.__source__ !== obj) {
// setup inherited copy of the listeners object
listeners = meta.listeners = create(listeners);
listeners = meta.listeners = Object.create(listeners);
listeners.__source__ = obj;
}

Expand Down
3 changes: 1 addition & 2 deletions packages/ember-metal/lib/injected_property.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Ember from "ember-metal/core"; // Ember.assert
import { ComputedProperty } from "ember-metal/computed";
import { AliasedProperty } from "ember-metal/alias";
import { Descriptor } from "ember-metal/properties";
import create from "ember-metal/platform/create";

/**
Read-only property that returns the result of a container lookup.
Expand Down Expand Up @@ -32,7 +31,7 @@ function injectedPropertyGet(keyName) {
return this.container.lookup(desc.type + ':' + (desc.name || keyName));
}

InjectedProperty.prototype = create(Descriptor.prototype);
InjectedProperty.prototype = Object.create(Descriptor.prototype);

var InjectedPropertyPrototype = InjectedProperty.prototype;
var ComputedPropertyPrototype = ComputedProperty.prototype;
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-metal/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
} from "ember-metal/utils";
import EmberError from "ember-metal/error";
import Cache from "ember-metal/cache";
import create from 'ember-metal/platform/create';
import Logger from "ember-metal/logger";

import {
Expand Down Expand Up @@ -225,8 +224,8 @@ Ember._Cache = Cache;

Ember.generateGuid = generateGuid;
Ember.GUID_KEY = GUID_KEY;
Ember.create = create;
Ember.keys = keys;
Ember.create = Object.create;
Ember.platform = {
defineProperty: true,
hasPropertyAccessors: true
Expand Down
Loading