Conversation
| function adjustTopBarHeight() { | ||
| if ( ! this.headerSlot_ ) return; | ||
| let root = this.document.documentElement; | ||
| this.headerSlot_.el().then(el => { |
There was a problem hiding this comment.
The old el() method returns a Promise, which is why you need to do a .then() to wait for the promise to resolve. But the new el_() method just returns the element directly, so then then() or await's are no longer needed. So this code would be converted to just:
root?.style.setProperty('--topbar-height', this.headerSlot_.el_().offsetHeight + 'px' );
src/foam/core/u2/navigation/Stack.js
Outdated
| }, | ||
| async function addHeaderObserver() { | ||
| const root = await this.el(); | ||
| const root = await this.el_(); |
There was a problem hiding this comment.
In this case, you would remove the 'await', which would also mean you could remove the 'async' from the function if this is the only place in the function that await is used.
| var resize = new ResizeObserver (this.adjustTopBarHeight); | ||
| this.onDetach(resize.disconnect()); | ||
| this.headerSlot_?.el().then(el => { | ||
| this.headerSlot_?.el_().then(el => { |
There was a problem hiding this comment.
There is also a then() here.. do we need to get rid of that, as well?
There was a problem hiding this comment.
let el = this.headerSlot_?.el_();
if ( el ) resize.observe(el);
OR
if ( this.headerSlot_ ) resize.observe(this.headerSlot_.el_());
There is no need for a then() anymore because el_() returns the element directly rather than via a Promise.
There was a problem hiding this comment.
Makes sense, thank you!
| this.headerSlot_.el().then(el => { | ||
| root?.style.setProperty('--topbar-height', el.offsetHeight + 'px' ); | ||
| }) | ||
| root?.style.setProperty('--topbar-height', el.offsetHeight + 'px' ); |
There was a problem hiding this comment.
This one looks wrong. Where does 'el' come from? Previously it came from this.headerSlot_.el().
| .addClass(this.myClass('img')).end(); | ||
|
|
||
| this.el().then((v) => { | ||
| this.el_().then((v) => { |
There was a problem hiding this comment.
No then(), since it is synchronous.
| this.SUPER(); | ||
|
|
||
| this.out$.sub(() => this.el().then(e => e.scrollTop = e.scrollHeight)); | ||
| this.out$.sub(() => this.el_().then(e => e.scrollTop = e.scrollHeight)); |
| // U2 or U3 | ||
| var a = start('b'); | ||
| a.el().then(el => el.innerHTML = 'foobar'); | ||
| a.el_().then(el => el.innerHTML = 'foobar'); |
There was a problem hiding this comment.
No then.
Just a.el_().innerHTML = 'foobar';
| } | ||
|
|
||
| var el = await this.el(); | ||
| var el = await this.el_(); |
There was a problem hiding this comment.
No need for 'await' since it is sync.
| async function onDelete() { | ||
| // do the deletion | ||
| var el = await this.childNodes[this.currentIndex].el(); | ||
| var el = await this.childNodes[this.currentIndex].el_(); |
| async function render() { | ||
| var parent = this.parentNode; | ||
| var parentE = await parent.el(); | ||
| var parentE = await parent.el_(); |
| isFramed: true, | ||
| code: async function() { | ||
| var el = await this.el(); | ||
| var el = await this.el_(); |
| async function eToObj(event) { | ||
| /** Find the object associated with a DOM element. **/ | ||
| var me = await this.el(); | ||
| var me = await this.el_(); |
|
|
||
| async function setTooltip(evt) { | ||
| var el = await this.target.el(); | ||
| var el = await this.target.el_(); |
There was a problem hiding this comment.
No await. Remaining errors are of the same type as this or previous ones.
Fixes #4555