@@ -24,6 +24,13 @@ export interface RenderKwargs {
2424 level ?: number ;
2525}
2626
27+ /**
28+ * docs pages contain a #styling-hooks anchor as back compat for older versions of the page
29+ * to prevent this id from rendering more than once, we track the number of times each page
30+ * renders css custom properties.
31+ */
32+ const cssStylingHookIdTracker = new WeakSet ( ) ;
33+
2734export declare class DocsPageRenderer {
2835 public tagName : string ;
2936 public manifest : Manifest ;
@@ -136,13 +143,15 @@ export class DocsPage implements DocsPageRenderer {
136143 return this . templates . render ( 'properties.njk' , { content, properties, deprecated, ...kwargs } ) ;
137144 }
138145
139- /** Render a talbe of element CSS Custom Properties */
146+ /** Render a table of element CSS Custom Properties */
140147 renderCssCustomProperties ( content : string , kwargs : RenderKwargs = { } ) {
148+ const hasStylingHooks = cssStylingHookIdTracker . has ( this ) ;
149+ cssStylingHookIdTracker . add ( this ) ;
141150 const allCssProperties = this . manifest . getCssCustomProperties ( this . #packageTagName( kwargs ) ) ?? [ ] ;
142151 const cssProperties = allCssProperties . filter ( x => ! x . deprecated ) ;
143152 const deprecated = allCssProperties . filter ( x => x . deprecated ) ;
144153
145- return this . templates . render ( 'css-custom-properties.njk' , { content, cssProperties, deprecated, ...kwargs } ) ;
154+ return this . templates . render ( 'css-custom-properties.njk' , { content, cssProperties, deprecated, hasStylingHooks , ...kwargs } ) ;
146155 }
147156
148157 /** Render the list of element CSS Shadow Parts */
@@ -152,7 +161,7 @@ export class DocsPage implements DocsPageRenderer {
152161 const parts = allParts . filter ( x => ! x . deprecated ) ;
153162 const deprecated = allParts . filter ( x => x . deprecated ) ;
154163
155- return this . templates . render ( 'css-shadow-parts.njk' , { parts, deprecated, content, ...kwargs , } ) ;
164+ return this . templates . render ( 'css-shadow-parts.njk' , { parts, deprecated, content, ...kwargs } ) ;
156165 }
157166
158167 /** Render the list of events for the element */
0 commit comments