Browse Source

Omit passProps from layout declaration

passProps are handled in Js and should not go over the bridge as they aren’t serialisable.
Fixes #3969
Guy Carmeli 6 years ago
parent
commit
68cd0379f2

+ 3
- 3
lib/src/commands/Commands.test.ts View File

230
 
230
 
231
   describe('push', () => {
231
   describe('push', () => {
232
     it('deep clones input to avoid mutation errors', () => {
232
     it('deep clones input to avoid mutation errors', () => {
233
-      const obj = {};
234
-      uut.push('theComponentId', { component: { name: 'name', passProps: { foo: obj } } });
235
-      expect(mockCommandsSender.push.mock.calls[0][2].data.passProps.foo).not.toBe(obj);
233
+      const options = {};
234
+      uut.push('theComponentId', { component: { name: 'name', options } });
235
+      expect(mockCommandsSender.push.mock.calls[0][2].data.options).not.toBe(options);
236
     });
236
     });
237
 
237
 
238
     it('resolves with the parsed layout', async () => {
238
     it('resolves with the parsed layout', async () => {

+ 12
- 0
lib/src/commands/LayoutTreeCrawler.test.ts View File

158
     expect(node.data.options).toEqual({});
158
     expect(node.data.options).toEqual({});
159
   });
159
   });
160
 
160
 
161
+  it('Components: omits passProps after processing so they are not passed over the bridge', () => {
162
+    const node = {
163
+      type: LayoutType.Component,
164
+      data: {
165
+        name: 'compName',
166
+        passProps: {}
167
+      }
168
+    };
169
+    uut.crawl(node);
170
+    expect(node.data.passProps).toBeUndefined();
171
+  });
172
+
161
   describe('navigation options', () => {
173
   describe('navigation options', () => {
162
     let options;
174
     let options;
163
     let node;
175
     let node;

+ 1
- 0
lib/src/commands/LayoutTreeCrawler.ts View File

44
     this._assertComponentDataName(node);
44
     this._assertComponentDataName(node);
45
     this._savePropsToStore(node);
45
     this._savePropsToStore(node);
46
     this._applyStaticOptions(node);
46
     this._applyStaticOptions(node);
47
+    node.data.passProps = undefined;
47
   }
48
   }
48
 
49
 
49
   _savePropsToStore(node) {
50
   _savePropsToStore(node) {