-
Notifications
You must be signed in to change notification settings - Fork 6
feat: make use of explicit JSON API #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see inline code comments
| expect(wrapper.html()).not.toContain('display: contents') | ||
| }) | ||
|
|
||
| it('renders only content prop when slot is empty', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
covered above already, drop
| expect(wrapper.html()).toBeTruthy() | ||
| }) | ||
|
|
||
| it('renders only slot when content prop is undefined', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
covered above already, drop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see inline code comments
Support for Explicit JSON API Format
NOTE: This summary was created with the help of AI, but thoroughly reviewed.
This PR adds support for a new, cleaner JSON format for custom elements with separated
propsandslotsobjects, while maintaining full backward compatibility with the legacy format.🎯 Overview
Custom elements can now use a more structured JSON format that clearly separates component properties from slot content, making the API more maintainable and easier to work with.
📊 API Comparison
Before (Legacy Format)
{ "element": "node-article-teaser", "title": "Article Title", "nid": 123, "default": "Content goes here", "sidebar": { "element": "drupal-block", "type": "search" } }Issues with legacy format:
After (Explicit Format)
{ "element": "node-article-teaser", "props": { "title": "Article Title", "nid": 123 }, "slots": { "default": "Content goes here", "sidebar": { "element": "drupal-block", "props": { "type": "search" } } } }🔧 Configuration
New option added:
customElementJsonFormatOptions:
'explicit'(default, recommended): Modern format with separatedpropsandslots'legacy': Legacy format with props and slots flattened at root level🔄 Backward Compatibility
This change is fully backward compatible:
Default behavior includes automatic fallback
'explicit'format (default) automatically detects and handles legacy formatGradual migration path
🎯 Recommended Configuration
For existing projects using older Drupal backends:
For new projects or after Drupal upgrade:
🔗 Drupal Integration
Drupal Module: custom_elements 3.3.0
The explicit JSON format will ship with custom_elements 3.3.0 on the Drupal side. Related backend change: https://www.drupal.org/project/custom_elements/issues/3555044
Drupal Configuration:
'legacy'format (no breaking changes)'explicit'format (recommended)📝 Changes Included
customElementJsonFormatconfiguration optionpropsandslotsseparation📚 Documentation
Full documentation added to README.md including: