Skip to content

Commit

Permalink
[CLEANUP] removed Ember.required
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Dec 26, 2017
1 parent cd61ae4 commit c0df986
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions packages/ember-metal/lib/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
deprecate
} from 'ember-debug';
import { DEBUG } from 'ember-env-flags';
import { ENV } from 'ember-environment';
import { descriptorFor, meta as metaFor, peekMeta } from './meta';
import expandProperties from './expand_properties';
import {
Expand Down Expand Up @@ -192,7 +193,7 @@ function applyMergedProperties(obj, key, value, values) {

function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) {
if (value instanceof Descriptor) {
if (value === REQUIRED && descs[key]) { return CONTINUE; }
if (ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT && value === REQUIRED && descs[key]) { return CONTINUE; }

// Wrap descriptor function to implement
// _super() if needed
Expand Down Expand Up @@ -355,7 +356,7 @@ function applyMixin(obj, mixins, partial) {
desc = descs[key];
value = values[key];

if (desc === REQUIRED) { continue; }
if (ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT && desc === REQUIRED) { continue; }

while (desc && desc instanceof Alias) {
let followed = followAlias(obj, desc, descs, values);
Expand Down
7 changes: 5 additions & 2 deletions packages/ember-metal/tests/mixin/required_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import {
required,
get
} from '../..';
import { ENV } from 'ember-environment';

let PartialMixin, FinalMixin, obj;

let originalEnvVal;
QUnit.module('Module.required', {
setup() {
originalEnvVal = ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT
ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT = true;
expectDeprecation(() => {
PartialMixin = Mixin.create({
foo: required(),
Expand All @@ -25,6 +28,7 @@ QUnit.module('Module.required', {

teardown() {
PartialMixin = FinalMixin = obj = null;
ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT = originalEnvVal;
}
});

Expand Down Expand Up @@ -54,4 +58,3 @@ QUnit.test('using apply', function() {
mixin(obj, PartialMixin, { foo: 'FOO' });
equal(get(obj, 'foo'), 'FOO', 'should now be defined');
});

10 changes: 6 additions & 4 deletions packages/ember-runtime/lib/system/core_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import ActionHandler from '../mixins/action_handler';
import { validatePropertyInjections } from '../inject';
import { assert } from 'ember-debug';
import { DEBUG } from 'ember-env-flags';
import { ENV } from 'ember-environment';
import { MANDATORY_SETTER } from 'ember/features';

const schedule = run.schedule;
Expand Down Expand Up @@ -553,10 +554,6 @@ CoreObject.__super__ = null;

let ClassMixinProps = {

ClassMixin: REQUIRED,

PrototypeMixin: REQUIRED,

isClass: true,

isMethod: false,
Expand Down Expand Up @@ -913,6 +910,11 @@ let ClassMixinProps = {
}
};

if (ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT) {
ClassMixinProps.ClassMixin = REQUIRED;
ClassMixinProps.PrototypeMixin = REQUIRED;
}

function injectedPropertyAssertion() {
assert('Injected properties are invalid', validatePropertyInjections(this));
}
Expand Down
1 change: 0 additions & 1 deletion packages/ember/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ Ember.observersFor = metal.observersFor;
Ember.removeObserver = metal.removeObserver;
Ember._suspendObserver = metal._suspendObserver;
Ember._suspendObservers = metal._suspendObservers;
Ember.required = metal.required;
Ember.aliasMethod = metal.aliasMethod;
Ember.observer = metal.observer;
Ember.mixin = metal.mixin;
Expand Down
1 change: 0 additions & 1 deletion packages/ember/tests/reexports_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ QUnit.module('ember reexports');
['removeObserver', 'ember-metal'],
['_suspendObserver', 'ember-metal'],
['_suspendObservers', 'ember-metal'],
['required', 'ember-metal'],
['aliasMethod', 'ember-metal'],
['observer', 'ember-metal'],
['mixin', 'ember-metal'],
Expand Down

0 comments on commit c0df986

Please sign in to comment.