-
Notifications
You must be signed in to change notification settings - Fork 611
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
fix: layer with shared encoding ignore repeater #9246
base: main
Are you sure you want to change the base?
Conversation
src/normalize/core.ts
Outdated
}, | ||
{config} | ||
); | ||
if (this.isEmpty(encoding) && !this.isEmpty(params.repeater)) { |
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.
Can we move this check to the second argument of the map unit method?
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.
ah yes, simplify and updated!
src/normalize/core.ts
Outdated
@@ -212,6 +211,13 @@ export class CoreNormalizer extends SpecMapper<NormalizerParams, FacetedUnitSpec | |||
|
|||
return super.mapFacet(spec, params); | |||
} | |||
// | |||
private isEmpty(obj: any) { |
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.
I think this should be a helper function outside of this class, no?
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.
Yes, move this outside the class
src/normalize/core.ts
Outdated
@@ -398,3 +405,10 @@ function mergeProjection<ES extends ExprRef | SignalRef>(opt: { | |||
} | |||
return projection ?? parentProjection; | |||
} | |||
|
|||
function emptyFlag(obj: any) { |
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.
I was thinking this should be it utils. We already have isEmpty
there so you could use that.
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.
Suggested code above.
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.
good to know that!
src/normalize/core.ts
Outdated
return this.mapUnit( | ||
{ | ||
...spec, | ||
...(mergedProjection ? {projection: mergedProjection} : {}), | ||
...(mergedEncoding ? {encoding: mergedEncoding} : {}) | ||
}, | ||
{config} | ||
emptyFlag(encoding) && !emptyFlag(params.repeater) |
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.
emptyFlag(encoding) && !emptyFlag(params.repeater) | |
isEmpty(encoding ?? {}) && ! isEmpty(params.repeater ?? {}) |
close #8734
I noticed that the main reason for the spec failed to replace
repeat
is due to there are some problem when handling the shared layer encoding, the params.repeater will be read when running mapUnit at the first time, but since in shared layer spec, the encoding will not be at the same layer as the repeater, and the repeater will not be record since mapUnitWithParentEncodingOrProjection will return config only, and therepeat
is thus cannot be replaced.I am not familiar with typescript so using some redundant code, I think this can be clean up and be more concised.