spyne 0.18.3 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import { baseCoreMixins } from '../utils/mixins/base-core-mixins';
2
2
  import {SpyneAppProperties} from '../utils/spyne-app-properties';
3
3
  import { deepMerge } from '../utils/deep-merge';
4
+ import {safeClone} from '../utils/safe-clone';
4
5
  import {
5
6
  findStrOrRegexMatchStr,
6
7
  getConstructorName
@@ -445,10 +446,11 @@ export class ViewStream {
445
446
  const elIsRendered = el => document.body.contains(el);
446
447
  const elIsReadyBool = propSatisfies(
447
448
  allPass([elIsRendered, elIsDomElement]), 'el');
448
-
449
449
  if (elIsReadyBool(this.props)) {
450
450
  this.updatePropsToMatchEl();
451
451
  this.postRender();
452
+ } else if(this.props.el === null){
453
+ console.error(`Spyne Error: The defined element for this ViewStream instance, ${this.constructor.name}, appears to not exist.`)
452
454
  }
453
455
  }
454
456
 
@@ -890,6 +892,13 @@ export class ViewStream {
890
892
  this.renderViewAndAttachToDom(node, 'dom', 'appendChild');
891
893
  }
892
894
 
895
+ appendToDomAfter(node){
896
+ if (this.props.el !== undefined){
897
+ console.warn(`Spyne Warning: The ViewStream, ${this.props.name}, has an element, ${this.props.el}, that is already rendered and does not need to be appendedToDomAfter. This may create unsusual side effects!`)
898
+ }
899
+ this.renderViewAndAttachToDom(node, 'dom', 'after');
900
+ }
901
+
893
902
  /**
894
903
  * Prepends the current ViewStream object to an existing dom element.
895
904
  * @param {HTMLElement} node the ViewStream child that is to be attached.
@@ -931,6 +940,10 @@ export class ViewStream {
931
940
  this.exchangeViewsWithChild(v, this.setAttachData('appendChild', query));
932
941
  }
933
942
 
943
+ appendViewAfter(v, query) {
944
+ this.exchangeViewsWithChild(v, this.setAttachData('after', query));
945
+ }
946
+
934
947
  /**
935
948
  * This method appends a child ViewStream object to a parent ViewStream object.
936
949
  * @param {ViewStream} v the ViewStream parent.
@@ -1286,7 +1299,7 @@ export class ViewStream {
1286
1299
  if (/CHANNEL_LIFECYCLE/.test(action)===false){
1287
1300
  Object.defineProperties(data, {
1288
1301
  payload: {
1289
- get: ()=> clone(pl)
1302
+ get: ()=> safeClone(pl)
1290
1303
 
1291
1304
  }
1292
1305
  })
@@ -31,8 +31,14 @@ describe('should test channel instance', () => {
31
31
  expect(props.sendCachedPayload).to.be.true;
32
32
  expect(actionsObj).to.deep.equal(finalActionsObj);
33
33
 
34
+ })
34
35
 
35
-
36
+ it('should update SpyneAppProperties doNotTrackList if doNotTrack is true', ()=>{
37
+ const channelName="CHANNEL_MY_TEST_CHANNEL";
38
+ const doNotTrack = true;
39
+ Channel.checkForNotTrackFlag({channelName, doNotTrack});
40
+ const untrackedChannelsArr = SpyneAppProperties.getUntrackedChannelsList()
41
+ expect(untrackedChannelsArr).to.deep.eq([channelName]);
36
42
  })
37
43
 
38
44
  });
@@ -64,6 +64,7 @@ describe('it should compare two objects for updated keys', () => {
64
64
 
65
65
  it('first comparison should be done against empty obj', () => {
66
66
  let compareStart = checkUpdatedKeys.compare(obj1);
67
+ console.log("compare start is ",compareStart);
67
68
  expect(compareStart.pathsChanged).to.deep.equal(['pageId', 'section']);
68
69
  });
69
70
 
@@ -39,7 +39,7 @@ describe('should test the ChannelDataPacketGenerator', () => {
39
39
  map.set(label, ChannelPayloadToTestFilters);
40
40
 
41
41
  const filterGateway = ChannelDataPacketGenerator.createFilterGateway(label, map);
42
- const pred = R.propEq('action', 'CHANNEL_ROUTE_CHANGE_EVENT');
42
+ const pred = R.propEq('CHANNEL_ROUTE_CHANGE_EVENT', 'action');
43
43
 
44
44
  const isCorrectAction = filterGateway(pred)
45
45
 
@@ -31,7 +31,7 @@ describe('DomElTemplate', () => {
31
31
  let data = {dog: {
32
32
  sound: 'woof'
33
33
  }};
34
- let template = "<h1>The dog says {{#dog}}{{sound}}{{/dog}}";
34
+ let template = "<h1>The dog says {{#dog}}{{sound}}{{/dog}}</h1>";
35
35
  let domElTemplate = new DomElementTemplate(template, data);
36
36
  let render = domElTemplate.renderDocFrag();
37
37
  expect(render.firstElementChild.innerText).to.equal('The dog says woof');
@@ -163,6 +163,23 @@ describe('DomElTemplate', () => {
163
163
  return true;
164
164
  });
165
165
 
166
+ it('DomElementTemplate should render index string value of an array',() =>{
167
+ const article = ["Usu at illum porro audire. Nam at ubique latine, vidit ocurreret pri ea, cu elitr nonumes mediocritatem nam.",
168
+ "Eu delenit meliore graecis sea. Sit id ubique commune, ius ne recusabo oportere similique, error putant usu ei.",
169
+ "Nam mutat saperet detracto eu, te ubique utamur aliquando pro. Ut verear probatus sea. Porro sonet euripidis ex est.",
170
+ "Mucius platonem eu per. Te utroque persecuti pro, error verterem scribentur no est.",
171
+ "An pro nibh salutatus, ea rebum aeterno complectitur has."];
172
+
173
+ const template = `<li>{{article.1}}</li>`;
174
+ const data = {article};
175
+ const domElTemplate = new DomElementTemplate(template, data);
176
+
177
+ const result = domElTemplate.renderToString();
178
+
179
+ expect(result).to.eq("<li>Eu delenit meliore graecis sea. Sit id ubique commune, ius ne recusabo oportere similique, error putant usu ei.</li>");
180
+
181
+ })
182
+
166
183
 
167
184
 
168
185
  });