spyne 0.21.1 → 0.21.4
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.
- package/SECURITY.md +8 -0
- package/lib/spyne.esm.js +2 -2
- package/lib/spyne.esm.js.map +1 -1
- package/lib/spyne.umd.js +2 -2
- package/lib/spyne.umd.js.LICENSE.txt +2 -2
- package/package.json +1 -1
- package/src/spyne/channels/spyne-channel-route.js +1 -1
- package/src/spyne/spyne-app.js +2 -2
- package/src/spyne/utils/spyne-app-properties.js +7 -0
- package/src/spyne/views/dom-element-template.js +4 -2
- package/src/tests/views/dom-el-template-proxy.test.js +8 -78
package/package.json
CHANGED
|
@@ -247,7 +247,7 @@ export class SpyneChannelRoute extends Channel {
|
|
|
247
247
|
// define an alias property using Object.defineProperty
|
|
248
248
|
Object.defineProperty(payload, 'linksData', {
|
|
249
249
|
get() {
|
|
250
|
-
console.warn('get links data is deprecated in ROUTE DEEPLINK DATA, use navLinks')
|
|
250
|
+
// console.warn('get links data is deprecated in ROUTE DEEPLINK DATA, use navLinks')
|
|
251
251
|
return this.navLinks
|
|
252
252
|
},
|
|
253
253
|
set(value) {
|
package/src/spyne/spyne-app.js
CHANGED
|
@@ -6,7 +6,7 @@ import { sanitizeHTMLConfigure } from './utils/sanitize-html.js'
|
|
|
6
6
|
import { sanitizeDataConfigure } from './utils/sanitize-data.js'
|
|
7
7
|
|
|
8
8
|
const _channels = new ChannelsMap()
|
|
9
|
-
const version = '0.21.
|
|
9
|
+
const version = '0.21.4'
|
|
10
10
|
|
|
11
11
|
class SpyneApplication {
|
|
12
12
|
/**
|
|
@@ -41,7 +41,7 @@ class SpyneApplication {
|
|
|
41
41
|
init(config = {}, testMode = false) {
|
|
42
42
|
// this.channels = new ChannelsMap();
|
|
43
43
|
/*!
|
|
44
|
-
* Spyne 0.21.
|
|
44
|
+
* Spyne 0.21.4
|
|
45
45
|
* https://spynejs.org
|
|
46
46
|
*
|
|
47
47
|
* @license
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SpyneUtilsChannelRoute } from './spyne-utils-channel-route.js'
|
|
2
|
+
import { SpyneUtilsChannelRouteUrl } from './spyne-utils-channel-route-url.js'
|
|
2
3
|
import { SpynePluginsMethods } from './spyne-plugins-methods.js'
|
|
3
4
|
import { deepMerge } from './deep-merge.js'
|
|
4
5
|
|
|
@@ -272,6 +273,12 @@ class SpyneAppPropertiesClass {
|
|
|
272
273
|
return _enableCMSProxies
|
|
273
274
|
}
|
|
274
275
|
|
|
276
|
+
getHrefFromData(routeProps={}){
|
|
277
|
+
|
|
278
|
+
return SpyneUtilsChannelRouteUrl.convertParamsToRoute(routeProps);
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
|
|
275
282
|
set enableCMSProxies(bool=true){
|
|
276
283
|
_enableCMSProxies = Boolean(bool);
|
|
277
284
|
}
|
|
@@ -8,8 +8,10 @@ export class DomElementTemplate {
|
|
|
8
8
|
this.isProxyData = data.__cms__isProxy === true
|
|
9
9
|
this.testMode = opts?.testMode
|
|
10
10
|
|
|
11
|
-
if (this.isProxyData === true
|
|
12
|
-
|
|
11
|
+
if (this.isProxyData === true) {
|
|
12
|
+
if (SpyneAppProperties.enableCMSProxies === true) {
|
|
13
|
+
this.template = SpyneAppProperties.formatTemplateForProxyData(this.template)
|
|
14
|
+
}
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const checkForArrayData = () => {
|
|
@@ -1,82 +1,12 @@
|
|
|
1
1
|
import { DomElementTemplate } from '../../spyne/views/dom-element-template';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
(!isPublic ? describe : describe.skip)('DomElementTemplate Proxy (Internal Test)', () => {
|
|
15
|
-
describe('formatTemplateForProxyData', () => {
|
|
16
|
-
it('should wrap text-node placeholders like <h1>{{title}}</h1> in <spyne-cms-item>', () => {
|
|
17
|
-
const input = '<h1>{{title}}</h1>';
|
|
18
|
-
const output = DomElementTemplate.formatTemplateForProxyData(input);
|
|
19
|
-
|
|
20
|
-
// wrapper exists
|
|
21
|
-
expect(output).to.include('<spyne-cms-item');
|
|
22
|
-
|
|
23
|
-
// text is preserved inside the CMS text wrapper
|
|
24
|
-
expect(output).to.include(
|
|
25
|
-
'<spyne-cms-item-text>{{title}}</spyne-cms-item-text>'
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// structural sanity check
|
|
29
|
-
expect(output).to.include('</spyne-cms-item>');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should NOT wrap attribute placeholders like <img src="{{imgUrl}}"> and keep them intact', () => {
|
|
33
|
-
const input = '<img src="{{imgUrl}}">';
|
|
34
|
-
const output = DomElementTemplate.formatTemplateForProxyData(input);
|
|
35
|
-
|
|
36
|
-
// attributes must remain untouched
|
|
37
|
-
expect(output).to.equal(input);
|
|
38
|
-
expect(output).to.not.include('<spyne-cms-item');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should allow prefixed attr* placeholders inside attributes without CMS wrapping', () => {
|
|
42
|
-
const input = '<img src="{{attrImgSrc}}" alt="{{attrImgAlt}}">';
|
|
43
|
-
const output = DomElementTemplate.formatTemplateForProxyData(input);
|
|
44
|
-
|
|
45
|
-
// attr* placeholders should remain intact
|
|
46
|
-
expect(output).to.include('{{attrImgSrc}}');
|
|
47
|
-
expect(output).to.include('{{attrImgAlt}}');
|
|
48
|
-
|
|
49
|
-
// no CMS proxy tags should be injected
|
|
50
|
-
expect(output).to.not.include('<spyne-cms-item');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should not wrap loop root elements or corrupt list structure', () => {
|
|
54
|
-
const input = `
|
|
55
|
-
<ul>
|
|
56
|
-
{{#items}}
|
|
57
|
-
<li><span>{{title}}</span></li>
|
|
58
|
-
{{/items}}
|
|
59
|
-
</ul>
|
|
60
|
-
`;
|
|
61
|
-
|
|
62
|
-
const data = {
|
|
63
|
-
__cms__isProxy: true,
|
|
64
|
-
items: [
|
|
65
|
-
{ title: 'A' },
|
|
66
|
-
{ title: 'B' },
|
|
67
|
-
{ title: 'C' }
|
|
68
|
-
]
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const tmpl = new DomElementTemplate(input, data);
|
|
72
|
-
const output = tmpl.renderToString();
|
|
73
|
-
|
|
74
|
-
// list structure must be preserved
|
|
75
|
-
expect(output.match(/<li>/g).length).to.equal(3);
|
|
76
|
-
|
|
77
|
-
// CMS proxy should exist only around text nodes
|
|
78
|
-
expect(output).to.include('<spyne-cms-item');
|
|
79
|
-
expect(output).to.not.match(/data-cms-key="<li/);
|
|
80
|
-
});
|
|
3
|
+
describe('DomElementTemplate (Public)', () => {
|
|
4
|
+
it('does not expose CMS proxy functionality', () => {
|
|
5
|
+
expect(
|
|
6
|
+
Object.prototype.hasOwnProperty.call(
|
|
7
|
+
DomElementTemplate,
|
|
8
|
+
'formatTemplateForProxyData'
|
|
9
|
+
)
|
|
10
|
+
).to.be.false;
|
|
81
11
|
});
|
|
82
12
|
});
|