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

fix: use weakmap instead of mutating object validation mixin is applied to #634

Merged
merged 1 commit into from
Apr 12, 2019
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
1 change: 0 additions & 1 deletion addon/-private/symbols.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const VALIDATIONS_CLASS = '__VALIDATIONS_CLASS__';
export const VALIDATIONS_MIXIN_COUNT = '__VALIDATIONS_MIXIN_COUNT__';
export const IS_VALIDATIONS_CLASS = '__IS_VALIDATIONS_CLASS__';
export const ATTRS_MODEL = '__ATTRS_MODEL__';
export const ATTRS_PATH = '__ATTRS_PATH__';
Expand Down
7 changes: 4 additions & 3 deletions addon/validations/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import {
} from '../utils/utils';
import {
VALIDATIONS_CLASS,
VALIDATIONS_MIXIN_COUNT,
IS_VALIDATIONS_CLASS,
ATTRS_MODEL,
ATTRS_PATH,
ATTRS_RESULT_COLLECTION
} from '../-private/symbols';

const VALIDATION_COUNT_MAP = new WeakMap();

/**
* ## Running Manual Validations
*
Expand Down Expand Up @@ -100,8 +101,8 @@ export default function buildValidations(validations = {}, globalOptions = {}) {
this._super(...arguments);

// Count number of mixins to bypass super check if there is more than 1
validationMixinCount = (get(this, VALIDATIONS_MIXIN_COUNT) || 0) + 1;
set(this, VALIDATIONS_MIXIN_COUNT, validationMixinCount);
validationMixinCount = (VALIDATION_COUNT_MAP.get(this) || 0) + 1;
VALIDATION_COUNT_MAP.set(this, validationMixinCount);
},
[VALIDATIONS_CLASS]: computed(function() {
if (!Validations) {
Expand Down