native-document 1.0.265 → 1.0.266
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 +1 -1
- package/src/router/link.js +13 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.266",
|
|
4
4
|
"description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
|
|
5
5
|
"author": "AfroCodeur <https://github.com/afrocodeur>",
|
|
6
6
|
"license": "MIT",
|
package/src/router/link.js
CHANGED
|
@@ -2,6 +2,8 @@ import Validator from '../core/utils/validator';
|
|
|
2
2
|
import {Link as NativeLink} from '../../elements';
|
|
3
3
|
import Router, {DEFAULT_ROUTER_NAME} from './Router';
|
|
4
4
|
import RouterError from './errors/RouterError';
|
|
5
|
+
import {getObservableParams, hasObservableParams} from '../i18n/service/functions';
|
|
6
|
+
import {Observable} from '../core/data/Observable';
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
export function Link(options, children){
|
|
@@ -18,7 +20,17 @@ export function Link(options, children){
|
|
|
18
20
|
if(!router) {
|
|
19
21
|
throw new RouterError('Router not found "'+routerName+'" for link "'+target.name+'"');
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
|
|
24
|
+
const dependencies = [ ...getObservableParams(target.params), ...getObservableParams(target.query)];
|
|
25
|
+
let url = '';
|
|
26
|
+
if(dependencies) {
|
|
27
|
+
url = Observable.computed(() => {
|
|
28
|
+
return router.generateUrl(target.name, target.params, target.query);
|
|
29
|
+
}, dependencies);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
url = router.generateUrl(target.name, target.params, target.query);
|
|
33
|
+
}
|
|
22
34
|
return NativeLink({ ...attributes, href: url }, children).nd.onPreventClick(() => {
|
|
23
35
|
router.push(url);
|
|
24
36
|
});
|