Skip to content

Commit

Permalink
fix(settings): change settings register order
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisha0 committed Jul 6, 2022
1 parent 9a24261 commit 033df78
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/plugins/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {UIPHeader} from './header/header';
import {UIPOptions} from './header/options/options';
import {UIPSnippets} from './header/snippets/snippets';
import {UIPSettings} from './settings/settings';
import {registeredSettings} from '../registration';

export {UIPEditor, UIPOptions, UIPSettings, UIPSnippets, UIPHeader};

Expand All @@ -11,5 +12,5 @@ export const registerPlugins = () => {
UIPHeader.register();
UIPOptions.register();
UIPSnippets.register();
UIPSettings.register();
registeredSettings().then(() => UIPSettings.register());
};
8 changes: 3 additions & 5 deletions src/plugins/settings/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export abstract class UIPSetting extends ESLBaseElement {
/** [Target's]{@link target} attribute which is changed by setting. */
@attr() public attribute: string;
/** Target to which setting's changes are attached. */
@attr() public target: string;
public get target(): string {
return this.getAttribute('target') || this.$settings.target;
}

@memoize()
public get $settings() {
Expand All @@ -29,10 +31,6 @@ export abstract class UIPSetting extends ESLBaseElement {
super.connectedCallback();
this.classList.add(UIPSetting.is);
this.bindEvents();

if (this.target) return;
const settingsTarget = this.$settings?.target;
if (settingsTarget) this.target = settingsTarget;
}

protected disconnectedCallback() {
Expand Down
9 changes: 9 additions & 0 deletions src/settings/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ export const registerSettings = () => {
UIPSelectSetting.register();
UIPSliderSetting.register();
};

export const registeredSettings = () => {
return Promise.all([
UIPBoolSetting.registered,
UIPTextSetting.registered,
UIPSelectSetting.registered,
UIPSliderSetting.registered,
]);
}

0 comments on commit 033df78

Please sign in to comment.