preact-material-components
preact-material-components copied to clipboard
Extend `mdcProps`
We should extend mdcProps
to either take in Strings as it does today or take objectsto accommodate non-boolean values as well.
as shown in #261.
This will allow simplify code for child components and we can use it later for DOM cleanup as suggested by @filoozom
@filoozom help me understand will this also cover #240 ?
Well, depends on the implementation. If _mdcProps
can take an object that says something like:
{
type: String, // defaults to Boolean
required: true, // defaults to false
addToParent: false // defaults to true
}
Then yes. The thing is that MaterialComponent
shouldn't just add all _mdcProps
to the element returned by materialDom()
, because some props are used on other elements. TextField
is a good example for that. Let's say we had:
constructor() {
this._mdcProps = {
src: {
type: String,
required: true,
addToParent: false
}
};
}
materialDom({ src }) {
return (
<div class="some-class">
<img src={src} />
</div>
);
}
And then src
should be removed from the element but src
should not be added to the div
.
I'm interested in this issue but I'm not sure I understand it 100%
Do you mean some fields in _mdcProps
that will determine which props are added to which element?
This could be interesting for 2.0