Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/props/Prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ let Self = class Prop {
}
}

if (spec.rawProp) {
// FIXME what if rawProp comes after this one?
let rawProp = this.props.get(spec.rawProp);
this.defaultProp ??= spec.rawProp;
rawProp.defaultProp ??= this.name;
}

if (spec.defaultProp) {
Object.defineProperty(this, "default", {
get: () => this.props.get(spec.defaultProp),
Expand All @@ -55,6 +62,10 @@ let Self = class Prop {
...inferDependencies(spec.convert),
...(spec.additionalDependencies ?? []),
]);

if (this.rawProp) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe here should be spec.rawProp?

this.dependencies.add(this.rawProp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here?

}
}

// Computed properties are not reflected by default
Expand Down
7 changes: 7 additions & 0 deletions src/props/Props.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ export default class Props extends Map {
}
}

if (prop.rawProp && element.props[prop.name] !== undefined && element.props[prop.rawProp] !== undefined) {
delete element.props[prop.rawProp];
let rawProp = this.get(prop.rawProp);
rawProp.defaultProp ??= prop;
this.propChanged(element, rawProp, {source: "property", value: element.props[prop.rawProp]});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this time, element.props[prop.rawProp] is already deleted, no? What value will be equal to?

}

// Fire propchange event
let eventNames = [ "propchange", ...(prop.eventNames ?? []) ];
for (let eventName of eventNames) {
Expand Down