Skip to content

Add support for lazy = true component flag to enforce lazy loading by default - #212

Merged
grantcopley merged 8 commits into
nextfrom
copilot/fix-4ae11d08-677c-4ec6-97b1-40cfefdf8a52
Nov 25, 2025
Merged

Add support for lazy = true component flag to enforce lazy loading by default#212
grantcopley merged 8 commits into
nextfrom
copilot/fix-4ae11d08-677c-4ec6-97b1-40cfefdf8a52

Conversation

Copilot AI commented Sep 25, 2025

Copy link
Copy Markdown
Contributor

Implementation Complete: Add Flag to Always Lazy Load a Component

Successfully implemented support for a lazy = true flag on CBWIRE components that enforces lazy loading by default, with full override capabilities using lazy=false in wire() calls.

✅ All Requirements Implemented

  1. Component Declaration: Components can declare lazy = true to be always lazy loaded
  2. Default Lazy Loading: Components with lazy = true are lazy loaded by default
  3. Override Capability: lazy=false in wire() calls overrides component's lazy preference
  4. Child Component Support: Child components with lazy = true also respect the lazy flag

✅ Implementation Summary

Files Modified:

  • models/Component.cfc: Updated lazy loading logic for both main components and child components
  • models/CBWIREController.cfc: Modified wire() method to respect component lazy preferences
  • test-harness/tests/specs/CBWIRESpec.cfc: Added comprehensive test suite and updated existing tests
  • test-harness/views/lazy-demo.cfm: Demo page with proper CFML pound sign escaping

Test Components Created:

  • TestAlwaysLazyComponent.cfc: Component with lazy = true
  • TestParentWithLazyChild.cfc: Parent component using lazy child
  • TestParentWithOverride.cfc: Parent overriding child's lazy setting

Test Coverage:

  • Component with lazy = true loads lazily by default
  • Override behavior with explicit lazy=false
  • Child components with lazy = true are lazy loaded
  • Parent components can override child lazy preferences
  • Explicit lazy=true parameter works correctly
  • Updated existing tests to use lazy instead of lazyLoad

✅ Key Features

  1. Minimal Implementation: All changes build on existing patterns, no breaking changes
  2. Consistent Behavior: Both CBWIREController.wire() and Component.wire() use same logic
  3. Full Override Support: Explicit parameters always take precedence over component preferences
  4. Comprehensive Testing: All scenarios covered with automated tests
  5. Clean API: Only supports lazy = true/false property as requested
  6. Proper CFML Syntax: Demo page uses correct pound sign escaping

Usage Examples

// Component with always lazy loading
component extends="cbwire.models.Component" {
    lazy = true;  // This component will always be lazy loaded by default
    // ...
}
<!-- Default behavior: lazy loaded due to component's lazy = true -->
#wire( name="UserActivity" )#

<!-- Override to force immediate rendering -->
#wire( name="UserActivity", lazy=false )#

The implementation is complete, tested, and ready for production use!

Original prompt

This section details on the original issue you should resolve

<issue_title>Add flag to always lazy load a component</issue_title>
<issue_description>Always Lazy Loading
To enforce that a CBWIRE component is always lazy-loaded, you can add lazy=true to the component class:

// ./wires/UserActivity.cfc
component extends="cbwire.models.Component" {
    lazy = true;
    // Other component methods...
}

If you want to override this default lazy-loading behavior, set the lazy parameter to false:

#wire( name="UserActivity", lazy=false )#
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

Fixes #152

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>
@grantcopley
grantcopley marked this pull request as ready for review September 25, 2025 15:07
Copilot AI and others added 2 commits September 25, 2025 15:09
Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>
Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>
Comment thread models/Component.cfc Outdated
variables._lazyLoad = variables.keyExists( "lazyLoad" ) && isBoolean( variables.lazyLoad ) && variables.lazyLoad ?
// Check if the component has a lazy property (preferred new syntax) or lazyLoad property (legacy)
variables._lazyLoad = ( variables.keyExists( "lazy" ) && isBoolean( variables.lazy ) && variables.lazy ) ||
( variables.keyExists( "lazyLoad" ) && isBoolean( variables.lazyLoad ) && variables.lazyLoad ) ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I don't want lazyLoad = true/false, just lazy = true/false on the component.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to only support lazy = true/false property on components. Removed the lazyLoad property support entirely and updated existing tests to use the new lazy property. Changes made in commit e0fb55f.

Copilot AI changed the title [WIP] Add flag to always lazy load a component Add support for lazy = true component flag to enforce lazy loading by default Sep 25, 2025
Copilot AI requested a review from grantcopley September 25, 2025 15:12
Comment thread test-harness/views/lazy-demo.cfm Outdated
<p>This page demonstrates the new <code>lazy = true</code> flag for CBWIRE components.</p>

<h2>Test 1: Component with lazy = true (should be lazy loaded)</h2>
<div style="border: 1px solid #ccc; padding: 10px; margin: 10px 0;">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot You have to escape pound signs in cfml with double pound ##.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the pound sign escaping. Changed #ccc to ##ccc in all CSS color codes within the cfoutput block. Changes made in commit 6314ebc.

Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>
Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>
@grantcopley grantcopley added this to the v5.0 milestone Nov 25, 2025
@github-actions

Copy link
Copy Markdown

lucee@5 Test Results

293 tests  +6   272 ✅ +6   5s ⏱️ ±0s
  8 suites ±0    21 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 9121c7e. ± Comparison against base commit 1f9f521.

@github-actions

Copy link
Copy Markdown

lucee@6 Test Results

293 tests  +6   272 ✅ +6   4s ⏱️ ±0s
  8 suites ±0    21 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 9121c7e. ± Comparison against base commit 1f9f521.

@github-actions

Copy link
Copy Markdown

boxlang-cfml@1 Test Results

293 tests  +6   275 ✅ +6   10s ⏱️ ±0s
  8 suites ±0    18 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 9121c7e. ± Comparison against base commit 1f9f521.

@github-actions

Copy link
Copy Markdown

adobe@2023 Test Results

293 tests  +6   272 ✅ +6   7s ⏱️ ±0s
  8 suites ±0    21 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 9121c7e. ± Comparison against base commit 1f9f521.

@github-actions

Copy link
Copy Markdown

adobe@2025 Test Results

293 tests  +6   272 ✅ +6   6s ⏱️ ±0s
  8 suites ±0    21 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 9121c7e. ± Comparison against base commit 1f9f521.

@grantcopley
grantcopley merged commit d98a255 into next Nov 25, 2025
13 checks passed
@grantcopley
grantcopley deleted the copilot/fix-4ae11d08-677c-4ec6-97b1-40cfefdf8a52 branch November 25, 2025 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants