Skip to content

Commit

Permalink
fixed load css of not compiled components
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Jan 23, 2025
1 parent 1160daf commit 184b0e7
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions hrt/impl/DomkitViewer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,24 @@ class DomkitViewer extends h2d.Object {
var loadedComponents : Array<domkit.Component<h2d.Object, h2d.Object>> = [];
var compHooks : Map<String,Array<Dynamic> -> h2d.Object -> h2d.Object> = [];
var definedClasses : Array<String> = [];
var loadedResources : Array<hxd.res.Resource>;
var loadedResources : Array<{ r : hxd.res.Resource, wasLoaded : Bool }> = [];

public function new( style : DomkitStyle, res : hxd.res.Resource, ?parent ) {
super(parent);
this.style = style;
this.resource = res;
loadedResources = [res];
res.watch(rebuild);
loadComponents(res);
addContext(new DomkitBaseContext());
rebuildDelay();
}

function loadComponents( res : hxd.res.Resource ) {
var loaded = @:privateAccess style.resources.indexOf(res) >= 0;
loadedResources.push({ r : res, wasLoaded: loaded });
if( !loaded ) style.load(res);
res.watch(rebuild);
}

function rebuildDelay() {
if( rebuilding ) return;
rebuilding = true;
Expand Down Expand Up @@ -264,8 +270,12 @@ class DomkitViewer extends h2d.Object {
if( currentObj != null )
currentObj.remove();
// force re-watch
for( r in loadedResources )
style.load(r);
for( r in loadedResources ) {
if( r.wasLoaded )
style.load(r.r);
else
style.unload(r.r);
}
for( c in loadedComponents ) {
@:privateAccess domkit.Component.COMPONENTS.remove(c.name);
@:privateAccess domkit.CssStyle.CssData.COMPONENTS.remove(c);
Expand Down

0 comments on commit 184b0e7

Please sign in to comment.