Pārlūkot izejas kodu

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 gadus atpakaļ
vecāks
revīzija
68cd0379f2

+ 3
- 3
lib/src/commands/Commands.test.ts Parādīt failu

@@ -230,9 +230,9 @@ describe('Commands', () => {
230 230
 
231 231
   describe('push', () => {
232 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 238
     it('resolves with the parsed layout', async () => {

+ 12
- 0
lib/src/commands/LayoutTreeCrawler.test.ts Parādīt failu

@@ -158,6 +158,18 @@ describe('LayoutTreeCrawler', () => {
158 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 173
   describe('navigation options', () => {
162 174
     let options;
163 175
     let node;

+ 1
- 0
lib/src/commands/LayoutTreeCrawler.ts Parādīt failu

@@ -44,6 +44,7 @@ export class LayoutTreeCrawler {
44 44
     this._assertComponentDataName(node);
45 45
     this._savePropsToStore(node);
46 46
     this._applyStaticOptions(node);
47
+    node.data.passProps = undefined;
47 48
   }
48 49
 
49 50
   _savePropsToStore(node) {