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

Enforce usage of capabilities generation. #19173

Merged
merged 1 commit into from
Sep 30, 2020
Merged

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Sep 30, 2020

Prior to this change it was possible to avoid using a given type's capabilities builder function (intentionally or on accident) by doing something like:

class MyManager {
  capabilities = {
    // magical properties from Ember's internals
  }
}

The API's that we intended folks to be using is something like:

import { capabilties as modifierCapabilities } from '@ember/modifier';

class MyManager {
  capabilities = modifierCapabilities('3.22');
}

This commit ensures that Ember's own internal structures can not be "spoofed" (avoiding our constraints, or creating a frankenstein manager).

@@ -17,6 +18,8 @@ const COMPONENT_MANAGERS = new WeakMap<
ManagerFactory<ComponentManagerDelegate<unknown> | InternalComponentManager>
>();

const FROM_CAPABILITIES = DEBUG ? new WeakSet() : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like the WeakSet polyfill is being used here, may be why browserstack is failing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for catching that!

Copy link
Contributor

@pzuraq pzuraq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, besides the IE11 issue!

Prior to this change it was possible to avoid using a given type's
`capabilities` builder function (intentionally or on accident) by doing
something like:

```js
class MyManager {
  capabilities = {
    // magical properties from Ember's internals
  }
}
```

The API's that we _intended_ folks to be using is something like:

```js
import { capabilties as modifierCapabilities } from '@ember/modifier';

class MyManager {
  capabilities = modifierCapabilities('3.22');
}
```

This commit ensures that Ember's own internal structures can not be
"spoofed" (avoiding our constraints, or creating a frankenstein
manager).
@rwjblue rwjblue merged commit 66fb044 into master Sep 30, 2020
@rwjblue rwjblue deleted the force-capabilities-usage branch September 30, 2020 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants