diff --git a/CHANGELOG.md b/CHANGELOG.md index 5905336d..2d6bbeba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 3.0.6 +* Remove static default values for `middleware`. + # 3.0.5 * Add `MiddlewarePipelineIterator`. diff --git a/lib/browser.dart b/lib/browser.dart index 01b77cde..b1a77218 100644 --- a/lib/browser.dart +++ b/lib/browser.dart @@ -72,7 +72,9 @@ abstract class _BrowserRouterImpl extends Router all(path, handler, middleware: middleware); void prepareAnchors() { - final anchors = window.document.querySelectorAll('a'); //:not([dynamic])'); + final anchors = window.document + .querySelectorAll('a') + .cast(); //:not([dynamic])'); for (final AnchorElement $a in anchors) { if ($a.attributes.containsKey('href') && diff --git a/lib/src/router.dart b/lib/src/router.dart index e36df6f8..d01297ec 100644 --- a/lib/src/router.dart +++ b/lib/src/router.dart @@ -69,7 +69,8 @@ class Router { /// for requests with the given method (case-insensitive). /// Provide '*' as the method to respond to all methods. Route addRoute(String method, String path, T handler, - {Iterable middleware: const []}) { + {Iterable middleware}) { + middleware ??= []; if (_useCache == true) throw new StateError('Cannot add routes after caching is enabled.'); @@ -164,7 +165,8 @@ class Router { /// Returns the created route. /// You can also register middleware within the router. SymlinkRoute group(String path, void callback(Router router), - {Iterable middleware: const [], String name: null}) { + {Iterable middleware, String name: null}) { + middleware ??= []; final router = new Router().._middleware.addAll(middleware); callback(router); return mount(path, router)..name = name; @@ -402,15 +404,16 @@ class _ChainedRouter extends Router { @override Route addRoute(String method, String path, handler, - {Iterable middleware: const []}) { + {Iterable middleware}) { var route = super.addRoute(method, path, handler, middleware: []..addAll(_handlers)..addAll(middleware ?? [])); //_root._routes.add(route); return route; } + @override SymlinkRoute group(String path, void callback(Router router), - {Iterable middleware: const [], String name: null}) { + {Iterable middleware, String name: null}) { final router = new _ChainedRouter(_root, []..addAll(_handlers)..addAll(middleware)); callback(router); diff --git a/pubspec.yaml b/pubspec.yaml index 3e4cf386..114560c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_route description: A powerful, isomorphic routing library for Dart. It is mainly used in the Angel framework, but can be used in Flutter and on the Web. -version: 3.0.5 +version: 3.0.6 author: Tobe O homepage: https://github.com/angel-dart/angel_route environment: