Skip to content

Commit f6fbd84

Browse files
committed
Do not return assets that have already been rendered.
1 parent c695350 commit f6fbd84

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

models/Component.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ component output="true" {
15591559
"method":"GET",
15601560
"children": variables._children.count() ? variables._children : [],
15611561
"scripts": variables._scripts.count() ? variables._scripts.keyArray() : [],
1562-
"assets":[],
1562+
"assets": variables._assets.count() ? variables._assets.keyArray() : [],
15631563
"isolate": variables._isolate,
15641564
"lazyLoaded": false,
15651565
"lazyIsolated": true,

test-harness/tests/specs/CBWIRESpec.cfc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,20 @@ component extends="coldbox.system.testing.BaseTestCase" {
329329
expect( result ).notToInclude( "tailwind.min.css" );
330330
} );
331331

332+
it( "should track assets in snapshot memo", function() {
333+
var result = CBWIREController.wire( "test.should_track_assets_in_snapshot_memo" );
334+
var parsing = parseRendering( result );
335+
expect( parsing.snapshot.memo.assets ).toBeArray();
336+
expect( parsing.snapshot.memo.assets.len() ).toBe( 1 );
337+
} );
338+
339+
it( "should not track assets in snapshot memo when lazy loaded", function() {
340+
var result = CBWIREController.wire( name="test.should_track_assets_in_snapshot_memo", lazy=true );
341+
var parsing = parseRendering( result );
342+
expect( parsing.snapshot.memo.assets ).toBeArray();
343+
expect( parsing.snapshot.memo.assets.len() ).toBe( 0 );
344+
} );
345+
332346
it( "should track scripts in snapshot memo", function() {
333347
var result = CBWIREController.wire( "test.should_track_scripts_in_snapshot_memo" );
334348
var parsing = parseRendering( result );
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<cfoutput>
2+
<div>
3+
<h1>Should track assets in snapshot memo</h1>
4+
</div>
5+
</cfoutput>
6+
7+
<cfscript>
8+
// @startWire
9+
function placeholder() {
10+
return "<div>This is a placeholder</div>";
11+
}
12+
// @endWire
13+
</cfscript>
14+
15+
<cbwire:assets>
16+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
17+
</cbwire:assets>

0 commit comments

Comments
 (0)