Skip to content

Commit 90e9d51

Browse files
namedgraphclaude
andcommitted
Preserve URL fragment identifier in history pushState
Two bugs caused fragment IDs (e.g. #select-children) to be stripped when the SPA rewrites the URL with the current layout mode: 1. ldh:HTMLDocumentLoaded passed only 2 args to ldh:href() when calling ldh:PushState, omitting the $fragment parameter — the 3-arg overload appends #fragment only when explicitly supplied. 2. The initial page load called ldh:HTMLDocumentLoaded without an explicit $href, so it defaulted to ldh:base-uri(.) = ac:absolute-path(ixsl:location()) which strips the fragment before pushState ever runs. Fixed by passing xs:anyURI(ixsl:location()) directly so the fragment is retained. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 00c745d commit 90e9d51

File tree

1 file changed

+2
-12
lines changed
  • src/main/webapp/static/com/atomgraph/linkeddatahub/xsl

1 file changed

+2
-12
lines changed

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ WHERE
302302
</xsl:when>
303303
<xsl:otherwise>
304304
<xsl:apply-templates select="ixsl:page()" mode="ldh:HTMLDocumentLoaded">
305+
<xsl:with-param name="href" select="xs:anyURI(ixsl:location())"/>
305306
<xsl:with-param name="endpoint" select="$sd:endpoint"/>
306307
<xsl:with-param name="container" select="id($body-id, ixsl:page())"/>
307308
<xsl:with-param name="replace-content" select="false()"/>
@@ -830,7 +831,7 @@ WHERE
830831

831832
<xsl:if test="$push-state">
832833
<xsl:call-template name="ldh:PushState">
833-
<xsl:with-param name="href" select="ldh:href($href, ldh:query-params(ac:mode()))"/>
834+
<xsl:with-param name="href" select="ldh:href($href, ldh:query-params(ac:mode()), $fragment)"/>
834835
<xsl:with-param name="title" select="/html/head/title"/>
835836
<xsl:with-param name="container" select="$container"/>
836837
</xsl:call-template>
@@ -847,17 +848,6 @@ WHERE
847848
</xsl:call-template>
848849
</xsl:template>
849850

850-
<!-- post-HTML load hook, mainly for navigation updates -->
851-
852-
<!-- <xsl:template name="ldh:PostHTMLDocumentLoad">
853-
<xsl:param name="href" as="xs:anyURI"/> possibly proxied URL
854-
855-
update the sidebar
856-
<xsl:call-template name="ldh:NavigationUpdate">
857-
<xsl:with-param name="href" select="$href"/>
858-
</xsl:call-template>
859-
</xsl:template>-->
860-
861851
<xsl:template name="ldt:AppChanged">
862852
<xsl:param name="base" as="xs:anyURI"/>
863853

0 commit comments

Comments
 (0)