@creative-web-solution/front-library 7.1.5 → 7.1.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 7.1.6
4
+
5
+ * Minor fix
6
+
3
7
 
4
8
  ## 7.1.5
5
9
 
@@ -9,7 +13,7 @@
9
13
  ## 7.1.4
10
14
 
11
15
  * Typescript: Fix tsify and browserify compatibility
12
-
16
+ * HistoryController: Remove UrlParser for window.URL
13
17
 
14
18
  ## 7.1.3
15
19
 
@@ -1,5 +1,4 @@
1
1
  import { on } from './EventsManager';
2
- import { UrlParser } from '../Helpers/UrlParser';
3
2
  import { slice } from '../Helpers/Slice';
4
3
 
5
4
 
@@ -33,7 +32,7 @@ export default class HistoryController {
33
32
  #hasPushstate: boolean;
34
33
  #hasPopStateEvent: boolean;
35
34
  #currentState: FLib.Events.History.StateObject;
36
- #registeredFunctionList: (( url: FLib.Helpers.UrlParser, state: any ) => void)[];
35
+ #registeredFunctionList: (( url: URL, state: any ) => void)[];
37
36
 
38
37
 
39
38
  get state(): FLib.Events.History.StateObject {
@@ -53,7 +52,7 @@ export default class HistoryController {
53
52
  this.#defaultTitle = encodeURIComponent( defaultTitle );
54
53
 
55
54
  this.#currentState = {
56
- "url": new UrlParser( window.location.href ),
55
+ "url": new window.URL( window.location.href ),
57
56
  "state": {},
58
57
  "title": this.#defaultTitle
59
58
  };
@@ -69,7 +68,7 @@ export default class HistoryController {
69
68
 
70
69
 
71
70
  // Call each registered function for popstate event
72
- #callRegisteredFunction = ( url: FLib.Helpers.UrlParser, state: any ): void => {
71
+ #callRegisteredFunction = ( url: URL, state: any ): void => {
73
72
  if ( !this.#registeredFunctionList.length ) {
74
73
  return;
75
74
  }
@@ -87,7 +86,7 @@ export default class HistoryController {
87
86
  }
88
87
 
89
88
  this.#currentState = {
90
- "url": new UrlParser( document.location.href ),
89
+ "url": new URL( document.location.href ),
91
90
  state,
92
91
  "title": ""
93
92
  };
@@ -101,15 +100,15 @@ export default class HistoryController {
101
100
  *
102
101
  * @param state - Native browser state object
103
102
  */
104
- pushState( state: any, title: string, url: string | UrlParser ): this {
103
+ pushState( state: any, title: string, url: string | URL ): this {
105
104
  if ( !this.#hasPushstate ) {
106
105
  return this;
107
106
  }
108
107
 
109
- url = url instanceof UrlParser ? url : new UrlParser( url as string );
108
+ url = url instanceof URL ? url : new URL( url as string );
110
109
 
111
110
  this.#currentState = {
112
- "url": url as UrlParser,
111
+ "url": url as URL,
113
112
  state,
114
113
  "title": title ? encodeURIComponent( title ) : this.#defaultTitle
115
114
  };
@@ -118,7 +117,7 @@ export default class HistoryController {
118
117
  window.history.pushState(
119
118
  state,
120
119
  this.#currentState.title,
121
- this.#currentState.url.absolute2
120
+ this.#currentState.url.href
122
121
  );
123
122
  }
124
123
  catch ( e ) {
@@ -137,14 +136,14 @@ export default class HistoryController {
137
136
  return this;
138
137
  }
139
138
 
140
- anchor = anchor.indexOf( '#' ) === -1 ? anchor : anchor.slice( 1 );
139
+ anchor = anchor.indexOf( '#' ) === -1 ? `#${ anchor }` : anchor;
141
140
 
142
141
  try {
143
- this.#currentState.url.setAnchor( anchor );
142
+ this.#currentState.url.hash = anchor.indexOf( '#' ) === -1 ? `#${ anchor }` : anchor;
144
143
  window.history.pushState(
145
144
  this.#currentState.state,
146
145
  this.#currentState.title,
147
- this.#currentState.url.absolute2
146
+ this.#currentState.url.href
148
147
  );
149
148
  }
150
149
  catch ( e ) {
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Front Library
2
2
 
3
- @version: 7.1.5
3
+ @version: 7.1.6
4
4
 
5
5
 
6
6
  ## Use
@@ -179,12 +179,12 @@ declare namespace FLib {
179
179
  */
180
180
  namespace History {
181
181
  type StateObject = {
182
- url: FLib.Helpers.UrlParser;
182
+ url: URL;
183
183
  state: any;
184
184
  title: string;
185
185
  }
186
186
 
187
- type Callback = ( url: FLib.Helpers.UrlParser, state: any ) => void;
187
+ type Callback = ( url: URL, state: any ) => void;
188
188
  }
189
189
 
190
190
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@creative-web-solution/front-library",
3
3
  "title": "Frontend library",
4
4
  "description": "Frontend functions and modules",
5
- "version": "7.1.5",
5
+ "version": "7.1.6",
6
6
  "homepage": "https://github.com/creative-web-solution/front-library",
7
7
  "author": "Creative Web Solution <contact@cws-studio.com> (https://www.cws-studio.com)",
8
8
  "keywords": [],