Skip to content

Fix hash routing bugs and add comprehensive test coverage#21

Merged
JosunLP merged 4 commits intodevelopmentfrom
copilot/sub-pr-16
Jan 26, 2026
Merged

Fix hash routing bugs and add comprehensive test coverage#21
JosunLP merged 4 commits intodevelopmentfrom
copilot/sub-pr-16

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 26, 2026

In hash routing mode, performNavigation was passing the full path (including ?query and #hash) to createRoute() as the pathname argument, breaking route matching when navigating to routes with query parameters or hash fragments. Additionally, getCurrentPath() had a bug parsing hash fragments in hash routing mode.

Changes:

  • src/router/router.ts:
    • Remove conditional toPath logic; always pass url.pathname to createRoute() in both hash and history modes
    • Fix getCurrentPath() to correctly parse hash fragments in hash mode by extracting the hash fragment (split by #) before query parameters (split by ?)
  • tests/router.test.ts: Add comprehensive hash routing test suite with 7 new tests covering all hash routing scenarios

Example:

Previously in hash mode, navigating to /page?foo=bar#section would fail to match a route defined as /page because the matcher received /page?foo=bar#section as the pathname.

// Before (broken in hash mode)
const toPath = useHash ? path : url.pathname;  // "/page?foo=bar#section" in hash mode
const to = createRoute(toPath, url.search, url.hash, flatRoutes);

// After (works in both modes)
const to = createRoute(url.pathname, url.search, url.hash, flatRoutes);

Additionally, hash fragment parsing was fixed:

// Before (broken for #/page#section)
const [pathname, rest = ''] = hashPath.split('?');
const [search, hashPart = ''] = rest.split('#');

// After (correctly handles all combinations)
const [pathWithQuery, hashPart = ''] = hashPath.split('#');
const [pathname, search = ''] = pathWithQuery.split('?');

Test Coverage:

The new test suite covers:

  • Basic hash routing navigation
  • Hash routing with query parameters
  • Hash routing with hash fragments
  • Hash routing with both query parameters and hash fragments
  • Hash routing with route parameters and query strings
  • Navigation guards in hash mode
  • Replace mode in hash routing

All 70 router tests pass, ensuring hash routing functionality is fully tested and protected against future regressions.


✨ 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: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to version 1.3.0 with new features and improvements Fix hash routing to pass pathname separately from query/hash Jan 26, 2026
Copilot AI requested a review from JosunLP January 26, 2026 09:53
@JosunLP JosunLP marked this pull request as ready for review January 26, 2026 09:56
Copilot AI review requested due to automatic review settings January 26, 2026 09:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in hash routing mode where route matching failed when navigating to routes with query parameters or hash fragments. The issue occurred because the full path string (including query and hash) was being passed as the pathname argument to createRoute(), preventing proper route matching.

Changes:

  • Remove conditional toPath logic that incorrectly passed the full path string in hash mode
  • Always use url.pathname, url.search, and url.hash separately for both hash and history routing modes

const url = new URL(path, window.location.origin);
const toPath = useHash ? path : url.pathname;
const to = createRoute(toPath, url.search, url.hash, flatRoutes);
const to = createRoute(url.pathname, url.search, url.hash, flatRoutes);
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

This fix resolves a bug in hash routing mode, but there are no tests covering hash routing functionality. The test suite should include tests for:

  1. Basic hash routing navigation
  2. Hash routing with query parameters (the specific bug this PR fixes)
  3. Hash routing with hash fragments
  4. Hash routing with both query parameters and hash fragments

Without test coverage, future changes could reintroduce this bug or create new issues in hash routing mode.

Copilot uses AI. Check for mistakes.
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.

Added comprehensive hash routing test coverage in b99b678:

  • Basic hash routing navigation (7 tests)
  • Hash routing with query parameters
  • Hash routing with hash fragments
  • Hash routing with both query and hash
  • Route parameters with query/hash in hash mode
  • Navigation guards in hash mode
  • Replace mode in hash routing

Also fixed a bug in getCurrentPath() where hash fragments weren't being extracted correctly in hash routing mode (the # should be split before the ?).

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Jan 26, 2026

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits January 26, 2026 10:04
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 26, 2026

@copilot apply changes based on the comments in this thread

Changes applied in commits b99b678 and 40272b3:

Added comprehensive hash routing tests:

  • 7 new test cases covering all hash routing scenarios
  • Tests for query parameters, hash fragments, and combinations
  • Tests for route parameters, navigation guards, and replace mode

Fixed hash fragment parsing bug:

  • getCurrentPath() now correctly extracts hash fragments in hash mode
  • URL structure #/path?query#fragment is now properly parsed

All 70 router tests pass with full coverage of hash routing functionality.

Copilot AI changed the title Fix hash routing to pass pathname separately from query/hash Fix hash routing bugs and add comprehensive test coverage Jan 26, 2026
@JosunLP JosunLP requested a review from Copilot January 26, 2026 10:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@JosunLP JosunLP merged commit c7389fc into development Jan 26, 2026
11 checks passed
@JosunLP JosunLP deleted the copilot/sub-pr-16 branch January 26, 2026 10:11
JosunLP added a commit that referenced this pull request Jan 31, 2026
* Refactor motion module: Split functionality into separate files and enhance type definitions

- Moved transition, flip, spring, stagger, timeline, keyframes, scroll, and reduced motion functionalities into their respective files for better organization and maintainability.
- Introduced new types for better type safety and clarity across the motion module.
- Added keyframe presets for common animations and scroll-triggered animation helpers.
- Implemented a prefers-reduced-motion detection utility.
- Enhanced tests to cover new functionalities and ensure robustness.

* Füge Sicherheitsmodule hinzu: Modularisiere interne Logik, implementiere Trusted Types und verbessere die HTML-Sanitierung

* - **Router**: Internals modularized into focused submodules with no public API changes.

### Fixed (Unreleased)

- **Security**: `security/sanitize` now re-exports `generateNonce()` and `isTrustedTypesSupported()` for legacy deep imports.

* Füge defineComponent-Funktion hinzu und modularisiere Komponentenlogik in Submodule

* Füge linkedSignal-Funktion hinzu: Erstelle schreibbare berechnete Werte, die Getter und Setter verknüpfen

* feat(store): implement devtools integration and refactor store structure

- Add devtools integration for store management with functions to register, unregister, and notify state changes.
- Refactor store module to separate concerns into distinct files: create-store, mapping, persisted, plugins, registry, types, utils, and watch.
- Introduce mapping helpers for state, getters, and actions to simplify component integration.
- Implement persistence functionality for stores using localStorage.
- Add watch functionality to observe state changes with customizable options.
- Enhance tests to cover new features including mapGetters and watchStore.

* feat(view): implement directive handlers for dynamic binding

- Add handleStyle directive for dynamic style binding in style.ts
- Add handleText directive for setting text content in text.ts
- Create evaluate function for expression evaluation in evaluate.ts
- Refactor view module by moving mount and template creation logic to mount.ts
- Introduce processElement and processChildren functions for directive processing in process.ts
- Define types for binding context, mount options, and directive handlers in types.ts
- Update index.ts to export new module structure and types

* feat(core): add attribute helpers and collection DOM manipulation methods

* feat(core): modularize utility functions into focused helper modules

* feat(component): sanitize markup in defineComponent to enhance security

* feat(security): sanitize component render markup for Shadow DOM consistency
fix(docs): correct event section heading in Core API guide for BQueryElement

* feat(release): bump version to 1.3.0 and update changelog

* feat(docs): update module sizes in README and add module overview in getting started guide

* feat(security): enhance mXSS detection in sanitizeHtmlCore by verifying stability through double-parsing

* Potential fix for code scanning alert no. 9: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix PR review issues: duplicate keys, cleanup leaks, export conflicts, and SSR safety (#17)

* Initial plan

* fix: address PR review comments - duplicate keys, cleanup, exports, unwrap, caching, routing, SSR, directives, and test

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: improve duplicate key warning message to be more accurate

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: add coverage for PR fixes - unwrap siblings, defineStore caching, ref cleanup, duplicate keys

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: improve duplicate key test with try-finally and reduce duplication

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: clarify unwrap() behavior for all children vs collection-only elements

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Update src/router/router.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/core/index.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* feat(security): implement safe HTML parsing with DOMParser and enhance mXSS detection

* Potential fix for code scanning alert no. 12: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix security, type safety, and API surface issues from PR #16 review (#18)

* Initial plan

* fix: address PR review comments - router guards, motion kebab-case, component styles, utils exports, docs

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* feat(security): enhance HTML parsing with input normalization and early return for plain text

* feat(security): implement dedicated HTML parsing helper to enhance safety and clarity

* Fix router cancellation, component example, and ref directive expression handling (#19)

* Initial plan

* fix(router): restore full URL with query/hash and use replaceState on cancelled navigation

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs(component): update example to use addEventListener instead of inline onclick

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix(view): use rawValue for object refs in bq-ref directive to support expressions

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: add coverage for nested bq-ref expressions and router query/hash restoration on cancelled navigation

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix(component): use event delegation in example to survive re-renders; test: add search/hash assertions

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs(component): add disconnected hook to example for proper event listener cleanup

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix router compatibility, isDev default, style cleanup, and changelog format (#20)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix hash routing bugs and add comprehensive test coverage (#21)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix router base path handling, bq-if DOM stability, and CHANGELOG consistency (#22)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Add JsDelivr badge to README (#23)

* Fix defineComponent tests, store reactivity leak, view directive signal handling, and hash-routing interception (#24)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix async handling, type safety, environment guards, and add test coverage from PR #16 review (#25)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix DOM order reversal, stale dependency tracking, localStorage SafariError, and reactive bq-for updates (#26)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix view template root validation, store optimizations, and utils API cleanup (#27)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Fix bq-show display restoration and timeline.seek() time calculation (#28)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix router base path duplication and add SSR guards for Element checks (#29)

* Initial plan

* Fix router base path duplication and add SSR guards for Element checks

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix SSR safety for interceptLinks default parameter and null router handling

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Address PR review comments: add window guard, fix base="/" edge case, clarify error comments, and add test coverage

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix window guard short-circuit and remove trailing whitespace

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix interceptLinks() browser behavior and createTemplate() validation (#30)

* Initial plan

* Fix interceptLinks() to respect browser behaviors and improve createTemplate() validation

- Add guards for standard browser behaviors in interceptLinks():
  * Only intercept left-clicks (button 0)
  * Respect Ctrl/Cmd/Shift/Alt modifier keys for new tabs
  * Skip already-prevented events
  * Check for MouseEvent type
- Add proper validation in createTemplate() to ensure exactly one root element
- Note: Did not change beforebegin reversal behavior as current implementation is correct

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Simplify createTemplate validation logic

Remove redundant check - since we already verified el exists, we only need to check for multiple roots

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Improve comment clarity in createTemplate validation

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Improve comment accuracy in validation and event handling

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Simplify comment for better clarity

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Add test coverage for browser behavior guards and template validation

- Add tests for interceptLinks() modifier key guards (Ctrl, Cmd, Shift, Alt)
- Add tests for interceptLinks() button checks (middle-click, right-click)
- Add test for interceptLinks() defaultPrevented check
- Add tests for createTemplate() multiple root element validation
- Add test for createTemplate() with whitespace handling
- All 422 tests pass

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix bq-class bracket detection, once() failure caching, mount bq-for validation, and component pre-mount renders (#31)

* Initial plan

* Fix bq-class array detection, once() failure handling, mount bq-for guard, and component pre-mount renders

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Add test coverage for once(), bq-class bracket access, mount bq-for validation, and component hasMounted

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix trailing whitespace in view tests

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Enhance prop coercion error handling, add Web Animations API check in timeline, and improve watch options with immediate and custom equality support

* Refactor tests to improve error message handling and update bq-class syntax; remove redundant bq-for test case

* Add GitHub Actions workflow for testing with Bun

* Potential fix for code scanning alert no. 16: Workflow does not contain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Refactor import statements for consistency, enhance untrack functionality to prevent dependency tracking for computed values, and add related tests

* Refactor imports for consistency, enhance Actions type to include getters, and clean up whitespace in various files

* Update warning message in bq-for tests to reflect index-based key fallback

* Implement lazy context proxy for signal unwrapping in evaluate function

* Format YAML and TypeScript files for consistency and readability

* Add early completion for flip animation on zero dimensions or no change

* Optimize evaluation functions by implementing caching for compiled expressions

* Füge Typdefinitionen für die Sicherheitsfunktionen hinzu und optimiere die Typumwandlung in der Prop-Koerzierungsfunktion

* Optimiere den Cache für evaluateRaw-Funktionen und verbessere die Schlüsselgenerierung

* Update README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Verbessere die Handhabung von Funktionsreferenzen in der bq-on:event-Direktive und optimiere die Cache-Logik in defineStore

* Verbessere die Typisierung und Validierung in der generateNonce-Funktion, füge Chunking für die String-Erstellung hinzu; aktualisiere die truncate-Dokumentation und verbessere die Proxy-Implementierung in createLazyContext

* Füge eine LRU-Cache-Implementierung für die Auswertung von Ausdrücken hinzu und verbessere die Cache-Verwaltung; implementiere Tests für die Cache-Leerung

* Verbessere die Handhabung von Leerzeichen in der class-Direktive und aktualisiere die Bun-Version in der CI-Konfiguration

* Aktualisiere die Bun-Version auf 1.3.7 in den CI-Konfigurationen und verbessere die Fehlerbehandlung beim Erstellen der Trusted Types-Policy.

* Verbessere die Handhabung der erforderlichen Eigenschaften im defineComponent und führe eine verzögerte Initialisierung des Mounts durch; aktualisiere die Typdefinitionen für die merge-Funktion zur Unterstützung von bis zu 5 Quellen.

* Füge Fallback für SSR/non-DOM-Umgebungen in der transition-Funktion hinzu und verbessere die Handhabung von localStorage in den Tests.

* Fix bq-style whitespace handling and spring variable frame rate (#32)

* Initial plan

* Fix bq-style whitespace handling and spring variable frame rate

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Improve documentation for spring variable frame rate timing

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Add test for bq-style directive with leading whitespace

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix bq-on method reference context loss and remove style attribute from security defaults (#33)

* Initial plan

* Fix bq-on method reference docs and remove style from default allowed attributes

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix persistedSignal localStorage test key collision (#34)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix bq-class directive stale class cleanup for object syntax (#35)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Fix timeline() to account for animation iterations in duration calculations (#36)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix createTemplate to reject templates with bq-if directive on the root element

* Fix test job permissions in GitHub Actions workflow

* Fix timeline to conditionally apply final keyframe styles based on commitStyles flag

* Fix createRouter to correctly handle base path matching for navigation

* 🔀 Update CHANGELOG.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix handleShow to ensure cross-document compatibility for computed display values

* Enhance prop coercion by adding explicit control for constructor invocation in PropDefinition

* Update devDependencies to latest versions for improved compatibility

* chore: update dependencies in package.json and improve test readability

- Updated eslint-config-prettier from ^9.1.2 to ^10.1.8
- Updated globals from ^15.15.0 to ^17.2.0
- Updated rimraf from ^5.0.10 to ^6.1.2
- Updated typedoc from ^0.25.13 to ^0.28.16
- Updated vite from ^5.4.21 to ^7.3.1
- Cleaned up whitespace in view.test.ts for better readability

* refactor: simplify logic for ordering elements in insertContent function

* refactor: enhance type handling in handleRef for improved clarity and safety

* refactor: clarify logic for reversing element order in insertContent function

* docs: update documentation for new features and improvements across modules

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
JosunLP added a commit that referenced this pull request Feb 10, 2026
* Refactor motion module: Split functionality into separate files and enhance type definitions

- Moved transition, flip, spring, stagger, timeline, keyframes, scroll, and reduced motion functionalities into their respective files for better organization and maintainability.
- Introduced new types for better type safety and clarity across the motion module.
- Added keyframe presets for common animations and scroll-triggered animation helpers.
- Implemented a prefers-reduced-motion detection utility.
- Enhanced tests to cover new functionalities and ensure robustness.

* Füge Sicherheitsmodule hinzu: Modularisiere interne Logik, implementiere Trusted Types und verbessere die HTML-Sanitierung

* - **Router**: Internals modularized into focused submodules with no public API changes.

### Fixed (Unreleased)

- **Security**: `security/sanitize` now re-exports `generateNonce()` and `isTrustedTypesSupported()` for legacy deep imports.

* Füge defineComponent-Funktion hinzu und modularisiere Komponentenlogik in Submodule

* Füge linkedSignal-Funktion hinzu: Erstelle schreibbare berechnete Werte, die Getter und Setter verknüpfen

* feat(store): implement devtools integration and refactor store structure

- Add devtools integration for store management with functions to register, unregister, and notify state changes.
- Refactor store module to separate concerns into distinct files: create-store, mapping, persisted, plugins, registry, types, utils, and watch.
- Introduce mapping helpers for state, getters, and actions to simplify component integration.
- Implement persistence functionality for stores using localStorage.
- Add watch functionality to observe state changes with customizable options.
- Enhance tests to cover new features including mapGetters and watchStore.

* feat(view): implement directive handlers for dynamic binding

- Add handleStyle directive for dynamic style binding in style.ts
- Add handleText directive for setting text content in text.ts
- Create evaluate function for expression evaluation in evaluate.ts
- Refactor view module by moving mount and template creation logic to mount.ts
- Introduce processElement and processChildren functions for directive processing in process.ts
- Define types for binding context, mount options, and directive handlers in types.ts
- Update index.ts to export new module structure and types

* feat(core): add attribute helpers and collection DOM manipulation methods

* feat(core): modularize utility functions into focused helper modules

* feat(component): sanitize markup in defineComponent to enhance security

* feat(security): sanitize component render markup for Shadow DOM consistency
fix(docs): correct event section heading in Core API guide for BQueryElement

* feat(release): bump version to 1.3.0 and update changelog

* feat(docs): update module sizes in README and add module overview in getting started guide

* feat(security): enhance mXSS detection in sanitizeHtmlCore by verifying stability through double-parsing

* Potential fix for code scanning alert no. 9: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix PR review issues: duplicate keys, cleanup leaks, export conflicts, and SSR safety (#17)

* Initial plan

* fix: address PR review comments - duplicate keys, cleanup, exports, unwrap, caching, routing, SSR, directives, and test

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: improve duplicate key warning message to be more accurate

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: add coverage for PR fixes - unwrap siblings, defineStore caching, ref cleanup, duplicate keys

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: improve duplicate key test with try-finally and reduce duplication

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: clarify unwrap() behavior for all children vs collection-only elements

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Update src/router/router.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/core/index.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* feat(security): implement safe HTML parsing with DOMParser and enhance mXSS detection

* Potential fix for code scanning alert no. 12: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix security, type safety, and API surface issues from PR #16 review (#18)

* Initial plan

* fix: address PR review comments - router guards, motion kebab-case, component styles, utils exports, docs

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* feat(security): enhance HTML parsing with input normalization and early return for plain text

* feat(security): implement dedicated HTML parsing helper to enhance safety and clarity

* Fix router cancellation, component example, and ref directive expression handling (#19)

* Initial plan

* fix(router): restore full URL with query/hash and use replaceState on cancelled navigation

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs(component): update example to use addEventListener instead of inline onclick

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix(view): use rawValue for object refs in bq-ref directive to support expressions

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: add coverage for nested bq-ref expressions and router query/hash restoration on cancelled navigation

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix(component): use event delegation in example to survive re-renders; test: add search/hash assertions

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs(component): add disconnected hook to example for proper event listener cleanup

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix router compatibility, isDev default, style cleanup, and changelog format (#20)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix hash routing bugs and add comprehensive test coverage (#21)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix router base path handling, bq-if DOM stability, and CHANGELOG consistency (#22)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Add JsDelivr badge to README (#23)

* Fix defineComponent tests, store reactivity leak, view directive signal handling, and hash-routing interception (#24)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix async handling, type safety, environment guards, and add test coverage from PR #16 review (#25)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix DOM order reversal, stale dependency tracking, localStorage SafariError, and reactive bq-for updates (#26)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix view template root validation, store optimizations, and utils API cleanup (#27)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Fix bq-show display restoration and timeline.seek() time calculation (#28)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix router base path duplication and add SSR guards for Element checks (#29)

* Initial plan

* Fix router base path duplication and add SSR guards for Element checks

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix SSR safety for interceptLinks default parameter and null router handling

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Address PR review comments: add window guard, fix base="/" edge case, clarify error comments, and add test coverage

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix window guard short-circuit and remove trailing whitespace

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix interceptLinks() browser behavior and createTemplate() validation (#30)

* Initial plan

* Fix interceptLinks() to respect browser behaviors and improve createTemplate() validation

- Add guards for standard browser behaviors in interceptLinks():
  * Only intercept left-clicks (button 0)
  * Respect Ctrl/Cmd/Shift/Alt modifier keys for new tabs
  * Skip already-prevented events
  * Check for MouseEvent type
- Add proper validation in createTemplate() to ensure exactly one root element
- Note: Did not change beforebegin reversal behavior as current implementation is correct

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Simplify createTemplate validation logic

Remove redundant check - since we already verified el exists, we only need to check for multiple roots

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Improve comment clarity in createTemplate validation

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Improve comment accuracy in validation and event handling

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Simplify comment for better clarity

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Add test coverage for browser behavior guards and template validation

- Add tests for interceptLinks() modifier key guards (Ctrl, Cmd, Shift, Alt)
- Add tests for interceptLinks() button checks (middle-click, right-click)
- Add test for interceptLinks() defaultPrevented check
- Add tests for createTemplate() multiple root element validation
- Add test for createTemplate() with whitespace handling
- All 422 tests pass

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix bq-class bracket detection, once() failure caching, mount bq-for validation, and component pre-mount renders (#31)

* Initial plan

* Fix bq-class array detection, once() failure handling, mount bq-for guard, and component pre-mount renders

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Add test coverage for once(), bq-class bracket access, mount bq-for validation, and component hasMounted

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix trailing whitespace in view tests

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Enhance prop coercion error handling, add Web Animations API check in timeline, and improve watch options with immediate and custom equality support

* Refactor tests to improve error message handling and update bq-class syntax; remove redundant bq-for test case

* Add GitHub Actions workflow for testing with Bun

* Potential fix for code scanning alert no. 16: Workflow does not contain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Refactor import statements for consistency, enhance untrack functionality to prevent dependency tracking for computed values, and add related tests

* Refactor imports for consistency, enhance Actions type to include getters, and clean up whitespace in various files

* Update warning message in bq-for tests to reflect index-based key fallback

* Implement lazy context proxy for signal unwrapping in evaluate function

* Format YAML and TypeScript files for consistency and readability

* Add early completion for flip animation on zero dimensions or no change

* Optimize evaluation functions by implementing caching for compiled expressions

* Füge Typdefinitionen für die Sicherheitsfunktionen hinzu und optimiere die Typumwandlung in der Prop-Koerzierungsfunktion

* Optimiere den Cache für evaluateRaw-Funktionen und verbessere die Schlüsselgenerierung

* Update README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Verbessere die Handhabung von Funktionsreferenzen in der bq-on:event-Direktive und optimiere die Cache-Logik in defineStore

* Verbessere die Typisierung und Validierung in der generateNonce-Funktion, füge Chunking für die String-Erstellung hinzu; aktualisiere die truncate-Dokumentation und verbessere die Proxy-Implementierung in createLazyContext

* Füge eine LRU-Cache-Implementierung für die Auswertung von Ausdrücken hinzu und verbessere die Cache-Verwaltung; implementiere Tests für die Cache-Leerung

* Verbessere die Handhabung von Leerzeichen in der class-Direktive und aktualisiere die Bun-Version in der CI-Konfiguration

* Aktualisiere die Bun-Version auf 1.3.7 in den CI-Konfigurationen und verbessere die Fehlerbehandlung beim Erstellen der Trusted Types-Policy.

* Verbessere die Handhabung der erforderlichen Eigenschaften im defineComponent und führe eine verzögerte Initialisierung des Mounts durch; aktualisiere die Typdefinitionen für die merge-Funktion zur Unterstützung von bis zu 5 Quellen.

* Füge Fallback für SSR/non-DOM-Umgebungen in der transition-Funktion hinzu und verbessere die Handhabung von localStorage in den Tests.

* Fix bq-style whitespace handling and spring variable frame rate (#32)

* Initial plan

* Fix bq-style whitespace handling and spring variable frame rate

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Improve documentation for spring variable frame rate timing

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Add test for bq-style directive with leading whitespace

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix bq-on method reference context loss and remove style attribute from security defaults (#33)

* Initial plan

* Fix bq-on method reference docs and remove style from default allowed attributes

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix persistedSignal localStorage test key collision (#34)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix bq-class directive stale class cleanup for object syntax (#35)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Fix timeline() to account for animation iterations in duration calculations (#36)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix createTemplate to reject templates with bq-if directive on the root element

* Fix test job permissions in GitHub Actions workflow

* Fix timeline to conditionally apply final keyframe styles based on commitStyles flag

* Fix createRouter to correctly handle base path matching for navigation

* 🔀 Update CHANGELOG.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix handleShow to ensure cross-document compatibility for computed display values

* Enhance prop coercion by adding explicit control for constructor invocation in PropDefinition

* Update devDependencies to latest versions for improved compatibility

* chore: update dependencies in package.json and improve test readability

- Updated eslint-config-prettier from ^9.1.2 to ^10.1.8
- Updated globals from ^15.15.0 to ^17.2.0
- Updated rimraf from ^5.0.10 to ^6.1.2
- Updated typedoc from ^0.25.13 to ^0.28.16
- Updated vite from ^5.4.21 to ^7.3.1
- Cleaned up whitespace in view.test.ts for better readability

* refactor: simplify logic for ordering elements in insertContent function

* refactor: enhance type handling in handleRef for improved clarity and safety

* refactor: clarify logic for reversing element order in insertContent function

* docs: update documentation for new features and improvements across modules

* fix: Reactive robustness, security hardening, storage compat, expression parsing (#37)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix css() getter, add Signal.dispose(), debounce/throttle cancel, collection.find(), element.is() (#39)

* Initial plan

* fix: css() getter, add Signal.dispose(), effect error handling, debounce/throttle cancel, is(), find()

- Fix BQueryElement.css() to return computed style when used as getter
- Fix BQueryCollection.css() to return computed style from first element
- Add error handling in effect() to catch errors without breaking reactive graph
- Add Signal.dispose() method to clear all subscribers
- Add cancel() method to debounce() and throttle() return values
- Add BQueryElement.is() as jQuery-compatible alias for matches()
- Add BQueryCollection.find() for descendant querying
- Add getComputedStyle to test setup for happy-dom
- Add comprehensive tests for all changes

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* perf: use Set for deduplication in BQueryCollection.find()

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* refactor: address review feedback - delegate is() to matches(), use ownerDocument.defaultView for getComputedStyle, update css() JSDoc

- is() now delegates to this.matches() instead of duplicating the implementation
- css() getter uses ownerDocument.defaultView?.getComputedStyle() for cross-document/SSR safety
- Updated css() JSDoc @returns to describe getter/setter return types
- Same fix applied to BQueryCollection.css() getter

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: properly type debounced/throttled via Object.assign, add getComputedStyle guard in collection.css()

- Use Object.assign to create DebouncedFn/ThrottledFn with proper typing
- Add typeof getComputedStyle check in BQueryCollection.css() getter for SSR safety

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: add css() getter example to JSDoc, strengthen effect error test

- Add getter usage example to BQueryElement.css() JSDoc
- Verify effect continues working after catching an error

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: use strict undefined check for debounce timeoutId instead of truthiness

Handles edge case where setTimeout could return 0 in browser environments.

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: implement removeDependency to prevent stale references on signal disposal

* fix: update css() method signatures for better type safety

* fix: update css() method signatures for improved type handling

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* chore: update dependencies and version, improve code readability in evaluate.ts and security tests

* fix: update funding model comments for clarity and consistency

* feat: add Cline and Cursor rules, enhance Copilot instructions, and update AGENT.md for AI agent support
feat: implement new features in core API including css() getter, is() method, find() method, and debounce/throttle enhancements
fix: improve reactive system error handling and add Signal.dispose() method
fix: enhance security validations for srcset and form action attributes
docs: update README.md and API documentation with new features and usage examples
chore: add llms.txt for LLM optimization and project summary

* fix: update security rule to reference correct sanitize module path

* fix: add optional chaining to prevent errors when accessing defaultView
fix: reset timeoutId in debounce function to avoid unintended behavior

* fix: clarify srcset validation behavior in documentation and examples

* Update tests/view.test.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
JosunLP added a commit that referenced this pull request Mar 12, 2026
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Fix PR review issues: duplicate keys, cleanup leaks, export conflicts, and SSR safety (#17)
Fix security, type safety, and API surface issues from PR #16 review (#18)
Fix router cancellation, component example, and ref directive expression handling (#19)
Fix router compatibility, isDev default, style cleanup, and changelog format (#20)
Fix hash routing bugs and add comprehensive test coverage (#21)
Fix router base path handling, bq-if DOM stability, and CHANGELOG consistency (#22)
Fix defineComponent tests, store reactivity leak, view directive signal handling, and hash-routing interception (#24)
Fix async handling, type safety, environment guards, and add test coverage from PR #16 review (#25)
Fix DOM order reversal, stale dependency tracking, localStorage SafariError, and reactive bq-for updates (#26)
Fix view template root validation, store optimizations, and utils API cleanup (#27)
Fix bq-show display restoration and timeline.seek() time calculation (#28)
Fix router base path duplication and add SSR guards for Element checks (#29)
Fix interceptLinks() browser behavior and createTemplate() validation (#30)
Fix bq-class bracket detection, once() failure caching, mount bq-for validation, and component pre-mount renders (#31)
Fix bq-style whitespace handling and spring variable frame rate (#32)
Fix bq-on method reference context loss and remove style attribute from security defaults (#33)
Fix persistedSignal localStorage test key collision (#34)
Fix bq-class directive stale class cleanup for object syntax (#35)
Fix timeline() to account for animation iterations in duration calculations (#36)
fix: Reactive robustness, security hardening, storage compat, expression parsing (#37)
Fix css() getter, add Signal.dispose(), debounce/throttle cancel, collection.find(), element.is() (#39)
fix(ci): align ESLint workflow with repo CI conventions (#47)
fix: repair corrupted bun.lock breaking CI frozen-lockfile installs (#48)
Fix ESLint workflow failure caused by SARIF formatter runtime mismatch (#50)
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.

3 participants