Skip to content

Commit

Permalink
$mol_view: prevent race condition for mol_theme between host and plugin.
Browse files Browse the repository at this point in the history
$mol_plugin: return static attrs
  • Loading branch information
jin committed Nov 2, 2023
1 parent 10ee799 commit 9747f74
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 5 additions & 1 deletion dom/render/attributes/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ namespace $ {

let val = attrs[ name ] as any

if( val === null || val === false ) {
if( val === undefined ) {

continue

} if( val === null || val === false ) {

if( !el.hasAttribute( name ) ) continue

Expand Down
7 changes: 1 addition & 6 deletions plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ namespace $ {
export class $mol_plugin extends $mol_view {

override dom_node_external( next? : Element ) {
const host = $mol_owning_get<typeof this, $mol_wire_fiber<$mol_view, any, any>>( this )!.host!
return next ?? host.dom_node()
}

override attr_static() : { [ key : string ] : string|number|boolean } {
return {}
return next ?? $mol_owning_get<typeof this, $mol_wire_fiber<$mol_view, any, any>>( this )!.host!.dom_node()
}

override render() {
Expand Down
3 changes: 1 addition & 2 deletions view/view/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ namespace $ {

const attr = this.attr()
const style = this.style()
const fields = this.field()

$mol_dom_render_attributes( node , attr )
$mol_dom_render_styles( node , style )
Expand Down Expand Up @@ -386,7 +385,7 @@ namespace $ {

attr() {
return {
mol_theme: this.theme(),
mol_theme: this.theme() || undefined,
} as {}
}

Expand Down

0 comments on commit 9747f74

Please sign in to comment.