Replaced el.components mapping with component service weakmap

Old system was hard to track in terms of usage and it's application of
'components' properties directly to elements was shoddy.
This routes usage via the components service, with element-specific
component usage tracked via a local weakmap.
Updated existing found usages to use the new system.
This commit is contained in:
Dan Brown
2022-11-16 15:46:41 +00:00
parent 25c23a2e5f
commit be736b3939
9 changed files with 81 additions and 22 deletions

View File

@ -4,12 +4,11 @@ import {Component} from "./component";
export class UserSelect extends Component {
setup() {
this.container = this.$el;
this.input = this.$refs.input;
this.userInfoContainer = this.$refs.userInfo;
this.hide = this.$el.components.dropdown.hide;
onChildEvent(this.$el, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
onChildEvent(this.container, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
}
selectUser(event, userEl) {
@ -20,4 +19,10 @@ export class UserSelect extends Component {
this.hide();
}
hide() {
/** @var {Dropdown} **/
const dropdown = window.$components.firstOnElement(this.container, 'dropdown');
dropdown.hide();
}
}