@@ -1797,110 +1797,6 @@ function executeMorphdom(rootFromElement, rootToElement, modifiedFieldElements,
1797
1797
} ) ;
1798
1798
}
1799
1799
1800
- function isValueEmpty ( value ) {
1801
- if ( null === value || value === '' || undefined === value || ( Array . isArray ( value ) && value . length === 0 ) ) {
1802
- return true ;
1803
- }
1804
- if ( typeof value !== 'object' ) {
1805
- return false ;
1806
- }
1807
- for ( const key of Object . keys ( value ) ) {
1808
- if ( ! isValueEmpty ( value [ key ] ) ) {
1809
- return false ;
1810
- }
1811
- }
1812
- return true ;
1813
- }
1814
- function toQueryString ( data ) {
1815
- const buildQueryStringEntries = ( data , entries = { } , baseKey = '' ) => {
1816
- Object . entries ( data ) . forEach ( ( [ iKey , iValue ] ) => {
1817
- const key = baseKey === '' ? iKey : `${ baseKey } [${ iKey } ]` ;
1818
- if ( '' === baseKey && isValueEmpty ( iValue ) ) {
1819
- entries [ key ] = '' ;
1820
- }
1821
- else if ( null !== iValue ) {
1822
- if ( typeof iValue === 'object' ) {
1823
- entries = { ...entries , ...buildQueryStringEntries ( iValue , entries , key ) } ;
1824
- }
1825
- else {
1826
- entries [ key ] = encodeURIComponent ( iValue )
1827
- . replace ( / % 2 0 / g, '+' )
1828
- . replace ( / % 2 C / g, ',' ) ;
1829
- }
1830
- }
1831
- } ) ;
1832
- return entries ;
1833
- } ;
1834
- const entries = buildQueryStringEntries ( data ) ;
1835
- return Object . entries ( entries )
1836
- . map ( ( [ key , value ] ) => `${ key } =${ value } ` )
1837
- . join ( '&' ) ;
1838
- }
1839
- function fromQueryString ( search ) {
1840
- search = search . replace ( '?' , '' ) ;
1841
- if ( search === '' )
1842
- return { } ;
1843
- const insertDotNotatedValueIntoData = ( key , value , data ) => {
1844
- const [ first , second , ...rest ] = key . split ( '.' ) ;
1845
- if ( ! second ) {
1846
- data [ key ] = value ;
1847
- return value ;
1848
- }
1849
- if ( data [ first ] === undefined ) {
1850
- data [ first ] = Number . isNaN ( Number . parseInt ( second ) ) ? { } : [ ] ;
1851
- }
1852
- insertDotNotatedValueIntoData ( [ second , ...rest ] . join ( '.' ) , value , data [ first ] ) ;
1853
- } ;
1854
- const entries = search . split ( '&' ) . map ( ( i ) => i . split ( '=' ) ) ;
1855
- const data = { } ;
1856
- entries . forEach ( ( [ key , value ] ) => {
1857
- value = decodeURIComponent ( value . replace ( / \+ / g, '%20' ) ) ;
1858
- if ( ! key . includes ( '[' ) ) {
1859
- data [ key ] = value ;
1860
- }
1861
- else {
1862
- if ( '' === value )
1863
- return ;
1864
- const dotNotatedKey = key . replace ( / \[ / g, '.' ) . replace ( / ] / g, '' ) ;
1865
- insertDotNotatedValueIntoData ( dotNotatedKey , value , data ) ;
1866
- }
1867
- } ) ;
1868
- return data ;
1869
- }
1870
- class UrlUtils extends URL {
1871
- has ( key ) {
1872
- const data = this . getData ( ) ;
1873
- return Object . keys ( data ) . includes ( key ) ;
1874
- }
1875
- set ( key , value ) {
1876
- const data = this . getData ( ) ;
1877
- data [ key ] = value ;
1878
- this . setData ( data ) ;
1879
- }
1880
- get ( key ) {
1881
- return this . getData ( ) [ key ] ;
1882
- }
1883
- remove ( key ) {
1884
- const data = this . getData ( ) ;
1885
- delete data [ key ] ;
1886
- this . setData ( data ) ;
1887
- }
1888
- getData ( ) {
1889
- if ( ! this . search ) {
1890
- return { } ;
1891
- }
1892
- return fromQueryString ( this . search ) ;
1893
- }
1894
- setData ( data ) {
1895
- this . search = toQueryString ( data ) ;
1896
- }
1897
- }
1898
- class HistoryStrategy {
1899
- static replace ( url ) {
1900
- history . replaceState ( history . state , '' , url ) ;
1901
- }
1902
- }
1903
-
1904
1800
class UnsyncedInputsTracker {
1905
1801
constructor ( component , modelElementResolver ) {
1906
1802
this . elementEventListeners = [
@@ -2250,7 +2146,7 @@ class Component {
2250
2146
this . processRerender ( html , backendResponse ) ;
2251
2147
const liveUrl = await backendResponse . getLiveUrl ( ) ;
2252
2148
if ( liveUrl ) {
2253
- HistoryStrategy . replace ( new UrlUtils ( liveUrl + window . location . hash , window . location . origin ) ) ;
2149
+ history . replaceState ( history . state , '' , new URL ( liveUrl + window . location . hash , window . location . origin ) ) ;
2254
2150
}
2255
2151
this . backendRequest = null ;
2256
2152
thisPromiseResolve ( backendResponse ) ;
0 commit comments