native-document 1.0.292 → 1.0.294
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.294",
|
|
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",
|
|
@@ -239,6 +239,13 @@ Observable.value = function(data) {
|
|
|
239
239
|
if(data?.__$Observable) {
|
|
240
240
|
return data.val();
|
|
241
241
|
}
|
|
242
|
+
if(Validator.isJson(data)) {
|
|
243
|
+
const output = {};
|
|
244
|
+
for(const key in data) {
|
|
245
|
+
output[key] = Observable.value(data[key]);
|
|
246
|
+
}
|
|
247
|
+
return output;
|
|
248
|
+
}
|
|
242
249
|
return data;
|
|
243
250
|
};
|
|
244
251
|
|
package/src/router/Router.js
CHANGED
|
@@ -289,16 +289,24 @@ Router.get = function(name) {
|
|
|
289
289
|
|
|
290
290
|
Router.currentRoute = function(name = null) {
|
|
291
291
|
return Router.get(name).currentState().route;
|
|
292
|
-
}
|
|
292
|
+
};
|
|
293
293
|
|
|
294
294
|
Router.push = function(target, name = null) {
|
|
295
295
|
return Router.get(name).push(target);
|
|
296
296
|
};
|
|
297
297
|
|
|
298
|
+
Router.pushTo = function(routeName, params = {}, routerName = null) {
|
|
299
|
+
return Router.get(routerName).push({ name: routeName, params });
|
|
300
|
+
};
|
|
301
|
+
|
|
298
302
|
Router.replace = function(target, name = null) {
|
|
299
303
|
return Router.get(name).replace(target);
|
|
300
304
|
};
|
|
301
305
|
|
|
306
|
+
Router.replaceTo = function(routeName, params = {}, routerName = null) {
|
|
307
|
+
return Router.get(routerName).replace({ name: routeName, params });
|
|
308
|
+
};
|
|
309
|
+
|
|
302
310
|
Router.forward = function(name = null) {
|
|
303
311
|
return Router.get(name).forward();
|
|
304
312
|
};
|
|
@@ -104,7 +104,7 @@ export function RouterComponent(router, container) {
|
|
|
104
104
|
if (matchDepth === 0) {
|
|
105
105
|
container.appendChild(newLayers[0].element);
|
|
106
106
|
} else {
|
|
107
|
-
$mountedChainKeep[matchDepth - 1].anchor.replaceContent(newLayers[0]
|
|
107
|
+
$mountedChainKeep[matchDepth - 1].anchor.replaceContent(newLayers[0]?.element || slot);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import DebugManager from '../../core/utils/debug-manager.js';
|
|
2
|
+
import {Observable} from '../../core/data/Observable';
|
|
2
3
|
|
|
3
4
|
export default function HistoryRouter() {
|
|
4
5
|
|
|
@@ -12,8 +13,9 @@ export default function HistoryRouter() {
|
|
|
12
13
|
if(window.history.state && window.history.state.path === path) {
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
const resolvedParams = Observable.value(params);
|
|
17
|
+
window.history.pushState({ name: route.name(), params: resolvedParams, path}, route.name() || path , path);
|
|
18
|
+
this.handleRouteChange(route, resolvedParams, query, path);
|
|
17
19
|
} catch (e) {
|
|
18
20
|
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
19
21
|
}
|
package/types/router.d.ts
CHANGED
|
@@ -69,13 +69,15 @@ export interface Router {
|
|
|
69
69
|
mount(container: string | HTMLElement): HTMLElement;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export
|
|
73
|
-
create(options: { mode: 'memory' | 'history' | 'hash'; name?: string; entry?: string }, callback: (router: Router) => void): Router;
|
|
74
|
-
get(name?: string): Router;
|
|
75
|
-
push(target: string | { name: string; params?: RouteParams; query?: QueryParams }, name?: string): void;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
export declare namespace Router {
|
|
73
|
+
function create(options: { mode: 'memory' | 'history' | 'hash'; name?: string; entry?: string }, callback: (router: Router) => void): Router;
|
|
74
|
+
function get(name?: string): Router;
|
|
75
|
+
function push(target: string | { name: string; params?: RouteParams; query?: QueryParams }, name?: string): void;
|
|
76
|
+
function pushTo(routeName: string, params?: RouteParams, routerName?: string): void;
|
|
77
|
+
function replace(target: string | { name: string; params?: RouteParams; query?: QueryParams }, name?: string): void;
|
|
78
|
+
function replaceTo(routeName: string, params?: RouteParams, routerName?: string): void;
|
|
79
|
+
function forward(name?: string): void;
|
|
80
|
+
function back(name?: string): void;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
// Link component for router
|