@brightspace-ui/labs 2.33.1 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -114,5 +114,5 @@
114
114
  "resize-observer-polyfill": "^1",
115
115
  "webvtt-parser": "^2.1.2"
116
116
  },
117
- "version": "2.33.1"
117
+ "version": "2.34.0"
118
118
  }
@@ -222,31 +222,6 @@ describe('Page Routing', () => {
222
222
 
223
223
  ### Route order inversion issue
224
224
 
225
- There's currently an issue with the way registered routes are processed that can cause the order of matching to appear to be inverted. This is not noticeable in many cases since it's often the case that only a single route will match regardless of the order. This does however come up when dealing with wildcard (`*`) routes (e.g. 404 redirect routes).
225
+ This issue is resolved by default but the fix can be bypassed (for backwards compatibility) by setting the `disableRouteOrderFix` option to `true`.
226
226
 
227
- If you notice that you have to put any routes with wildcards (`*`) before those without instead of after, this is the reason why.
228
-
229
- #### Issue Fix
230
-
231
- There is currently a fix available for this ordering issue, but it requires setting the `enableRouteOrderFix` option to `true`. Ex:
232
-
233
- ```js
234
- registerRoutes([
235
- {
236
- pattern: '/home',
237
- view: () => html`...`
238
- },
239
- {
240
- pattern: '/404',
241
- view: () => html`...`
242
- },
243
- {
244
- pattern: '*',
245
- to: '/404'
246
- }
247
- ], {
248
- enableRouteOrderFix: true
249
- });
250
- ```
251
-
252
- Note: The reason this is an opt-in fix is that a lot of existing implementations of lit-router have worked around this issue by putting the wildcard routes at the start, which would break if the issue were fixed for everyone automatically.
227
+ Bypassing the fix causes a warning to appear in the dev console. To resolve the warning, remove the `disaableRouteOrderFix` option and thoroughly test your routing. If your routes contain wildcards (`*`, typically for 404s), you may need to register them last.
@@ -38,10 +38,10 @@ const _handleRouteView = (context, next, r) => {
38
38
  };
39
39
 
40
40
  const _handleRouteLoader = r => (context, next) => {
41
- const enableRouteOrderFix = _lastOptions?.enableRouteOrderFix ?? false;
41
+ const disableRouteOrderFix = _lastOptions?.disableRouteOrderFix ?? false;
42
42
 
43
43
  // Skip further pattern matches if the route has already been handled
44
- if (enableRouteOrderFix && context.handled) {
44
+ if (!disableRouteOrderFix && context.handled) {
45
45
  next();
46
46
  return;
47
47
  }
@@ -51,7 +51,7 @@ const _handleRouteLoader = r => (context, next) => {
51
51
  _handleRouteView(context, next, r);
52
52
  });
53
53
  } else if (r.pattern && r.to) {
54
- if (enableRouteOrderFix) {
54
+ if (!disableRouteOrderFix) {
55
55
  activePage.redirect(r.to);
56
56
  } else {
57
57
  activePage.redirect(r.pattern, r.to);
@@ -93,7 +93,7 @@ export const registerRoutes = (routes, options) => {
93
93
  if (hasRegistered) throw new Error('May not construct multiple routers.');
94
94
  hasRegistered = true;
95
95
 
96
- if (!options?.enableRouteOrderFix) console.warn('lit-router: The enableRouteOrderFix option is not enabled. This may cause issues with route handling. See here for details: https://github.com/BrightspaceUI/labs/tree/main/src/utilities/router#route-order-inversion-issue');
96
+ if (options?.disableRouteOrderFix) console.warn('lit-router: The disableRouteOrderFix option is enabled, which may cause issues with route handling. See here for details: https://github.com/BrightspaceUI/labs/tree/main/src/utilities/router#route-order-inversion-issue');
97
97
 
98
98
  configure(options);
99
99