Install
Works with Drupal: ^10 || ^11Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
## Overview
SDC Property Inheritance is a Drupal module that provides runtime inheritance for Single Directory Components (SDC). It allows replacement components (using `replaces:`) to omit their `props` schema, automatically inheriting the parent schema and avoiding duplication, while remaining fully compatible with Drupal core validation.
## Features
- **Automatic Prop Inheritance:**
- Replacement components can omit the `props` block; the parent component's schema is injected at runtime.
- Partial overrides are supported: only missing properties are merged in, and your overrides take precedence.
- New props in the child are always set to `required: false` for compatibility.
- **Library Overrides:**
- Inherits `libraryOverrides` from the parent if not defined in the child.
- **Compatibility Checks:**
- Ensures that child schemas cannot be stricter than the parent.
- Throws clear errors if replacement schemas are incompatible.
- **Debugging:**
- Adds a `_inherited` marker to merged definitions for easy verification.
- **Performance:**
- Inheritance logic runs once per discovery cache rebuild; results are cached for efficiency.
## Usage
- Place only metadata and `replaces:` in your override component if you only need to change Twig/CSS.
- For partial overrides, declare only the properties you want to override; the rest are inherited.
- See the README for full usage patterns and debugging tips.
## Limitations
- Does not attempt deep merging of nested `properties` schemas beyond one level.
- Only `props` and `libraryOverrides` are considered; slots are not modified.
- If the parent removes or renames a prop, children reflect that on the next cache rebuild.
- The debug key `_inherited` is internal and should not be used in production logic.
---
**In short:** Place only metadata + `replaces:` in your override component if all you need is Twig/CSS changes; this module lifts the parent schema in at runtime so core stays happy.