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

refactor: remove hard dependency of DI on FASTElement #6280

Merged
merged 7 commits into from
Aug 16, 2022
Prev Previous commit
Next Next commit
feat: throw if attempting to respect DOM connect without a FASTElement
  • Loading branch information
EisenbergEffect committed Aug 15, 2022
commit de092807f6dbd38f799db0447ceae58222662eb6
1 change: 1 addition & 0 deletions packages/web-components/fast-element/src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const debugMessages = {
[1511 /* invalidKey */]: "Key/value cannot be null or undefined. Are you trying to inject/register something that doesn't exist with DI?",
[1512 /* noDefaultResolver */]: "'${key}' not registered. Did you forget to add @singleton()?",
[1513 /* cyclicDependency */]: "Cyclic dependency found '${name}'.",
[1514 /* connectUpdateRequiresController */]: "Injected properties that are updated on changes to DOM connectivity require the target object to be an instance of FASTElement.",
};

const allPlaceholders = /(\$\{\w+?})/g;
Expand Down
5 changes: 5 additions & 0 deletions packages/web-components/fast-element/src/di/di.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,11 @@ export const DI = Object.freeze({

if (respectConnection) {
const notifier = (this as any).$fastController;

if (!notifier) {
throw FAST.error(Message.connectUpdateRequiresController);
}

const handleChange = () => {
const newContainer = DI.findResponsibleContainer(this);
const newValue = newContainer.get(key) as any;
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/fast-element/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export const enum Message {
invalidKey = 1511,
noDefaultResolver = 1512,
cyclicDependency = 1513,
connectUpdateRequiresController = 1514
}

/**
Expand Down