Skip to content

Commit

Permalink
add open attribute for details
Browse files Browse the repository at this point in the history
Allows the `details` element to be opened by default.
  • Loading branch information
seth-js committed Jan 1, 2025
1 parent 20a897f commit 9ece614
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ext/data/schemas/dictionary-term-bank-v3-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
"type": "string",
"description": "Hover text for the element."
},
"open": {
"type": "boolean",
"description": "Whether or not the details element is open by default."
},
"lang": {
"type": "string",
"description": "Defines the language of an element in the format defined by RFC 5646."
Expand Down
3 changes: 2 additions & 1 deletion ext/js/display/structured-content-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,12 @@ export class StructuredContentGenerator {
break;
}
if (hasStyle) {
const {style, title} = /** @type {import('structured-content').StyledElement} */ (content);
const {style, title, open} = /** @type {import('structured-content').StyledElement} */ (content);
if (typeof style === 'object' && style !== null) {
this._setStructuredContentElementStyle(node, style);
}
if (typeof title === 'string') { node.title = title; }
if (typeof open === 'boolean' && open) { node.setAttribute('open', ''); }
}
if (hasChildren) {
this._appendStructuredContent(node, content.content, dictionary, language);
Expand Down
4 changes: 4 additions & 0 deletions types/ext/structured-content.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ export type StyledElement = {
* Hover text for the element.
*/
title?: string;
/**
* Whether or not the details element is open by default.
*/
open?: boolean;
/**
* Defines the language of an element in the format defined by RFC 5646.
*/
Expand Down

0 comments on commit 9ece614

Please sign in to comment.