Skip to content

Commit 04b001b

Browse files
authoredSep 8, 2024··
revert(nodeOps): add check for null props (#829)
1 parent bea583f commit 04b001b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎src/core/nodeOps.test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ describe('nodeOps', () => {
129129
it('throws an error if tag does not exist in catalogue', () => {
130130
expect(() => { nodeOps.createElement('THIS_TAG_DOES_NOT_EXIST', undefined, undefined, {}) }).toThrow()
131131
})
132+
133+
it('does not throw an error if `props` is `null`', () => {
134+
expect(() => { nodeOps.createElement('TresPerspectiveCamera', undefined, undefined, null) }).not.toThrow()
135+
expect(() => { nodeOps.createElement('TresMesh', undefined, undefined, null) }).not.toThrow()
136+
expect(() => { nodeOps.createElement('TresBoxGeometry', undefined, undefined, null) }).not.toThrow()
137+
expect(() => { nodeOps.createElement('TresMeshNormalMaterial', undefined, undefined, null) }).not.toThrow()
138+
})
132139
})
133140

134141
describe('insert', () => {

‎src/core/nodeOps.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const supportedPointerEvents = [
3030
export const nodeOps: (context: TresContext) => RendererOptions<TresObject, TresObject | null> = (context) => {
3131
const scene = context.scene.value
3232

33-
function createElement(tag: string, _isSVG: undefined, _anchor: any, props: Partial<WithMathProps<TresObject>> = {}): TresObject | null {
33+
function createElement(tag: string, _isSVG: undefined, _anchor: any, props: Partial<WithMathProps<TresObject>> | null): TresObject | null {
34+
if (!props) { props = {} }
35+
3436
if (!props.args) {
3537
props.args = []
3638
}

0 commit comments

Comments
 (0)
Please sign in to comment.