Skip to content

Commit

Permalink
Fix resource.props doesn't resolve default props like parent
Browse files Browse the repository at this point in the history
  • Loading branch information
Polleps committed Nov 6, 2024
1 parent 524d990 commit 40ad7ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion browser/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"tslib": "^2.8.0",
"typescript": "^5.6.3",
"vite": "^5.4.10",
"vite-plugin-dts": "^3.9.1"
"vite-plugin-dts": "^3.9.1",
"vitest": "^2.1.3"
},
"files": [
"dist"
Expand Down
11 changes: 11 additions & 0 deletions browser/lib/src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export class Resource<C extends OptionalClass = any> {
* @example const description = resource.props.description
*/
public get props(): QuickAccesPropType<C> {
const defaultProps = {
parent: core.properties.parent,
isA: core.properties.isA,
write: core.properties.write,
read: core.properties.read,
};

// eslint-disable-next-line @typescript-eslint/no-this-alias
const innerThis = this;

Expand All @@ -121,6 +128,10 @@ export class Resource<C extends OptionalClass = any> {
.filter(def => def !== undefined);

const getPropSubject = (name: string) => {
if (name in defaultProps) {
return defaultProps[name];
}

for (const def of defs) {
const value = def[name];

Expand Down
3 changes: 3 additions & 0 deletions browser/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40ad7ff

Please sign in to comment.