@glitchr/transparent 1.0.40 → 1.0.41
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/js/transparent.js +7 -7
package/package.json
CHANGED
package/src/js/transparent.js
CHANGED
|
@@ -12,23 +12,23 @@
|
|
|
12
12
|
|
|
13
13
|
window.replaceHash = function(newHash, triggerHashChange = true, skipIfEmptyIdentifier = true) {
|
|
14
14
|
|
|
15
|
+
var oldHash = location.hash;
|
|
16
|
+
var oldURL = location.origin+location.pathname+location.hash;
|
|
17
|
+
var oldHashElement = $(oldHash);
|
|
18
|
+
|
|
15
19
|
if(!newHash) newHash = "";
|
|
16
20
|
if (newHash !== "" && (''+newHash).charAt(0) !== '#')
|
|
17
21
|
newHash = '#' + newHash;
|
|
18
|
-
|
|
19
|
-
var oldURL = location.origin+location.pathname+location.hash;
|
|
20
22
|
var newURL = location.origin+location.pathname+newHash;
|
|
23
|
+
var newHashElement = $(newHash);
|
|
21
24
|
|
|
22
25
|
var fallback = $(newHash).length === 0;
|
|
23
|
-
|
|
24
|
-
var hashElement = $(newHash)[0] ?? undefined;
|
|
25
|
-
// if (hashElement !== undefined) // Update hash only if element is displayed
|
|
26
|
-
// fallback |= window.getComputedStyle(hashElement)["display"] == "none";
|
|
26
|
+
fallback |= newHashElement.has(oldHashElement).length > 0;
|
|
27
27
|
|
|
28
28
|
if((skipIfEmptyIdentifier && !newHash) || fallback){
|
|
29
29
|
|
|
30
30
|
dispatchEvent(new HashChangeEvent("hashfallback", {oldURL:oldURL, newURL:newURL}));
|
|
31
|
-
newHash = "";
|
|
31
|
+
newHash = skipIfEmptyIdentifier && !newHash ? "" : (newHashElement.length == 0 ? "" : oldHash);
|
|
32
32
|
|
|
33
33
|
oldURL = location.origin+location.pathname+location.hash;
|
|
34
34
|
newURL = location.origin+location.pathname+newHash;
|