Skip to content

Commit

Permalink
Add parent getter for jexl/simplefeature
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 10, 2022
1 parent 4c0e1ba commit 2732f6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/core/util/jexl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export default function (/* config?: any*/): JexlNonBuildable {
j.addFunction('get', (feature: Feature, data: string) => {
return feature.get(data)
})
j.addFunction('parent', (feature: Feature) => {
return feature.parent()
})

j.addFunction('id', (feature: Feature) => {
return feature.id()
Expand Down
6 changes: 5 additions & 1 deletion packages/core/util/simpleFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ export default class SimpleFeature implements Feature {
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public get(name: string): any {
return name === 'subfeatures' ? this.subfeatures : this.data[name]
return name === 'subfeatures'
? this.subfeatures
: name === 'parent'
? this.parent()
: this.data[name]
}

/**
Expand Down

0 comments on commit 2732f6b

Please sign in to comment.