vsn 0.1.85 → 0.1.88

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.
Files changed (64) hide show
  1. package/demo/demo.html +17 -225
  2. package/demo/vsn.js +2 -2
  3. package/dist/AST/ClassNode.js +6 -1
  4. package/dist/AST/ClassNode.js.map +1 -1
  5. package/dist/Attribute.js +0 -3
  6. package/dist/Attribute.js.map +1 -1
  7. package/dist/Component.js +60 -0
  8. package/dist/Component.js.map +1 -1
  9. package/dist/DOM/DOMObject.js +2 -1
  10. package/dist/DOM/DOMObject.js.map +1 -1
  11. package/dist/DOM.d.ts +2 -2
  12. package/dist/DOM.js +78 -77
  13. package/dist/DOM.js.map +1 -1
  14. package/dist/Registry.d.ts +2 -0
  15. package/dist/Registry.js +6 -0
  16. package/dist/Registry.js.map +1 -1
  17. package/dist/Scope/ScopeData.js +0 -1
  18. package/dist/Scope/ScopeData.js.map +1 -1
  19. package/dist/Service.d.ts +9 -0
  20. package/dist/Service.js +49 -0
  21. package/dist/Service.js.map +1 -0
  22. package/dist/Tag.d.ts +1 -0
  23. package/dist/Tag.js +8 -6
  24. package/dist/Tag.js.map +1 -1
  25. package/dist/attributes/ControllerAttribute.d.ts +3 -1
  26. package/dist/attributes/ControllerAttribute.js +16 -6
  27. package/dist/attributes/ControllerAttribute.js.map +1 -1
  28. package/dist/attributes/JSONAttribute.js +4 -3
  29. package/dist/attributes/JSONAttribute.js.map +1 -1
  30. package/dist/attributes/ModelAttribute.d.ts +1 -0
  31. package/dist/attributes/ModelAttribute.js +13 -1
  32. package/dist/attributes/ModelAttribute.js.map +1 -1
  33. package/dist/attributes/ServiceAttribute.d.ts +7 -0
  34. package/dist/attributes/ServiceAttribute.js +45 -0
  35. package/dist/attributes/ServiceAttribute.js.map +1 -0
  36. package/dist/attributes/_imports.d.ts +1 -0
  37. package/dist/attributes/_imports.js +3 -1
  38. package/dist/attributes/_imports.js.map +1 -1
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/dist/vsn.d.ts +1 -0
  42. package/dist/vsn.js +3 -1
  43. package/dist/vsn.js.map +1 -1
  44. package/dist/vsn.min.js +3 -0
  45. package/dist/vsn.min.js.LICENSE.txt +9 -0
  46. package/package.json +1 -1
  47. package/src/AST/ClassNode.ts +7 -3
  48. package/src/Attribute.ts +0 -1
  49. package/src/Component.ts +8 -0
  50. package/src/DOM/DOMObject.ts +2 -1
  51. package/src/DOM.ts +22 -23
  52. package/src/Registry.ts +6 -0
  53. package/src/Scope/ScopeData.ts +0 -1
  54. package/src/Service.ts +24 -0
  55. package/src/Tag.ts +9 -6
  56. package/src/attributes/ControllerAttribute.ts +13 -5
  57. package/src/attributes/JSONAttribute.ts +3 -3
  58. package/src/attributes/ModelAttribute.ts +3 -0
  59. package/src/attributes/ServiceAttribute.ts +13 -0
  60. package/src/attributes/_imports.ts +1 -0
  61. package/src/version.ts +1 -1
  62. package/src/vsn.ts +1 -0
  63. package/test/attributes/JSONAttribute.spec.ts +31 -29
  64. package/test/attributes/ServiceAttribute.spec.ts +34 -0
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4
+ * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
+ * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
+ * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
+ * Code distributed by Google as part of the polymer project is also
8
+ * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vsn",
3
- "version": "0.1.85",
3
+ "version": "0.1.88",
4
4
  "description": "SEO Friendly Javascript/Typescript Framework",
5
5
  "keywords": [
6
6
  "framework",
@@ -73,8 +73,8 @@ export class ClassNode extends Node implements TreeNode {
73
73
  else
74
74
  dom.once('builtRoot', () => this.findClassElements(dom));
75
75
  }
76
- } else {
77
- await this.block.prepare(this.classScope, dom, tag, meta);
76
+ } else if (meta['PrepForSelector'] === this.fullSelector) { // Only prepare top level class if we're prepping for tag
77
+ await this.block.prepare(tag.scope, dom, tag, meta);
78
78
  }
79
79
  }
80
80
 
@@ -83,6 +83,7 @@ export class ClassNode extends Node implements TreeNode {
83
83
  for (const element of Array.from(dom.querySelectorAll(this.selector, tag))) {
84
84
  tags.push(await ClassNode.addElementClass(this._fullSelector, element as HTMLElement, dom, element[Tag.TaggedVariable] || null));
85
85
  }
86
+
86
87
  for (const childSelector of ClassNode.classChildren[this._fullSelector]) {
87
88
  const node = ClassNode.classes[`${this._fullSelector} ${childSelector}`];
88
89
  if (!node) continue;
@@ -98,6 +99,7 @@ export class ClassNode extends Node implements TreeNode {
98
99
 
99
100
  tag.createScope(true);
100
101
  const meta = this.updateMeta();
102
+ meta['PrepForSelector'] = this.fullSelector;
101
103
  await this.block.prepare(tag.scope, dom, tag, meta);
102
104
  if (hasConstruct) {
103
105
  const fncCls: FunctionNode = this.classScope.get('construct') as FunctionNode;
@@ -140,7 +142,9 @@ export class ClassNode extends Node implements TreeNode {
140
142
  if (t.type === TokenType.L_BRACE) break;
141
143
  nameParts.push(t.value);
142
144
  }
143
- const selector = nameParts.join('').trim();
145
+ let selector = nameParts.join('').trim();
146
+ if (selector.startsWith('>'))
147
+ selector = `:scope ${selector}`;
144
148
  tokens.splice(0, nameParts.length);
145
149
  const block = Tree.processTokens(Tree.getNextStatementTokens(tokens, true, true));
146
150
  return new ClassNode(selector, block);
package/src/Attribute.ts CHANGED
@@ -24,7 +24,6 @@ export abstract class Attribute extends EventDispatcher {
24
24
  ) {
25
25
  super();
26
26
  this.configure();
27
- if (VisionHelper.window) VisionHelper.window['Attributes'].push(this);
28
27
  }
29
28
 
30
29
  public get origin(): Tag {
package/src/Component.ts CHANGED
@@ -21,6 +21,14 @@ export class Component extends HTMLElement {
21
21
  this.setAttribute('vsn-ref', '');
22
22
 
23
23
  this.shadow.appendChild(template.content.cloneNode(true));
24
+ this.shadow.querySelectorAll('slot').forEach(slot => {
25
+ slot.addEventListener('slotchange', async (e) => {
26
+ for (const child of slot.assignedNodes()) {
27
+ const t = await DOM.instance.getTagForElement(child as HTMLElement, true, true);
28
+ t?.slotted(slot);
29
+ }
30
+ });
31
+ });
24
32
  DOM.instance.buildFrom(this.shadow);
25
33
  }
26
34
  }
@@ -22,8 +22,9 @@ export abstract class DOMObject extends EventDispatcher {
22
22
  if (this.isSlot) {
23
23
  this.delegates.push(...(element as HTMLSlotElement).assignedNodes() as HTMLElement[]);
24
24
  }
25
- if (element.assignedSlot)
25
+ if (element.assignedSlot) {
26
26
  this.slot = element.assignedSlot;
27
+ }
27
28
  }
28
29
 
29
30
  public get isSlot(): boolean {
package/src/DOM.ts CHANGED
@@ -189,42 +189,41 @@ export class DOM extends EventDispatcher {
189
189
  }
190
190
  }
191
191
 
192
- async buildFrom(ele: any, isRoot: boolean = false) {
193
- // Assign parents to each tag
194
- const allElements: HTMLElement[] = [];
195
-
192
+ async buildFrom(ele: any, isRoot: boolean = false, forComponent: boolean = false) {
196
193
  if (isRoot) {
197
194
  document.body.setAttribute('vsn-root', '');
198
195
  document.ondragover = (e) => e.cancelable && e.preventDefault(); // Allow dragging over document
199
196
  }
200
197
 
201
- for (const tag of this.tags)
202
- allElements.push(tag.element);
203
-
204
198
  // Create tags for each html element with a v-attribute
205
199
  const newTags: Tag[] = [];
206
200
  const toBuild: HTMLElement[] = [];
207
- const toSkip: HTMLElement[] = [];
208
-
209
- if (ele && ele.querySelectorAll) {
210
- for (const element of (Array.from(ele.querySelectorAll(`*`)) as HTMLElement[])) { // Don't build items more than once
211
- if (!ElementHelper.hasVisionAttribute(element)) continue;
212
- if ((element.hasAttribute('vsn-template') && element.tagName === 'template') || toSkip.indexOf(element.parentElement) > -1) {
213
- toSkip.push(element);
214
- continue;
215
- }
216
- if (this.queued.indexOf(element) > -1) continue;
217
- this.queued.push(element);
218
- toBuild.push(element);
201
+
202
+ const checkElement = (e: HTMLElement) => {
203
+ if (ElementHelper.hasVisionAttribute(e)) {
204
+ if (
205
+ (!forComponent && e.hasAttribute('slot'))
206
+ ) return;
207
+ if (this.queued.indexOf(e) > -1) return;
208
+ this.queued.push(e);
209
+ toBuild.push(e);
210
+ }
211
+ }
212
+ const scanChildren = (e: HTMLElement) => {
213
+ for (const element of Array.from(e.children) as HTMLElement[]) {
214
+ checkElement(element);
215
+ if (element.tagName.toLowerCase() !== 'template')
216
+ scanChildren(element);
219
217
  }
220
218
  }
219
+ checkElement(ele);
220
+ scanChildren(ele);
221
221
 
222
222
  for (const element of toBuild) {
223
- if (allElements.indexOf(element) > -1) continue;
223
+ if (element[Tag.TaggedVariable]) continue;
224
224
  const tag: Tag = new Tag(element, this);
225
225
  this.tags.push(tag);
226
226
  newTags.push(tag);
227
- allElements.push(element as HTMLElement);
228
227
  }
229
228
 
230
229
  if (isRoot)
@@ -295,14 +294,14 @@ export class DOM extends EventDispatcher {
295
294
  return tags;
296
295
  }
297
296
 
298
- async getTagForElement(element: Element, create: boolean = false) {
297
+ async getTagForElement(element: Element, create: boolean = false, forComponent: boolean = false) {
299
298
  if (element[Tag.TaggedVariable])
300
299
  return element[Tag.TaggedVariable];
301
300
 
302
301
  if (element && create) {
303
302
  if (element instanceof HTMLElement)
304
303
  element.setAttribute('vsn-ref', '');
305
- await this.buildFrom(element.parentElement || element);
304
+ await this.buildFrom(element.parentElement || element, false, forComponent);
306
305
  return await this.getTagForElement(element, false);
307
306
  }
308
307
 
package/src/Registry.ts CHANGED
@@ -68,6 +68,7 @@ export class Registry extends EventDispatcher {
68
68
  public readonly classes: RegistryStore;
69
69
  public readonly models: RegistryStore;
70
70
  public readonly templates: RegistryStore;
71
+ public readonly services: RegistryStore;
71
72
  public readonly types: RegistryStore;
72
73
  public readonly validators: RegistryStore;
73
74
  public readonly formats: RegistryStore;
@@ -81,6 +82,7 @@ export class Registry extends EventDispatcher {
81
82
  this.classes = new RegistryStore();
82
83
  this.models = new RegistryStore();
83
84
  this.templates = new RegistryStore<HTMLTemplateElement>();
85
+ this.services = new RegistryStore();
84
86
  this.types = new RegistryStore();
85
87
  this.validators = new RegistryStore();
86
88
  this.formats = new RegistryStore();
@@ -111,6 +113,10 @@ export class Registry extends EventDispatcher {
111
113
  return register('templates', key, setup);
112
114
  }
113
115
 
116
+ public static service(key: string = null, setup = null) {
117
+ return register('services', key, setup);
118
+ }
119
+
114
120
  public static type(key: string = null, setup = null) {
115
121
  return register('types', key, setup);
116
122
  }
@@ -9,7 +9,6 @@ export class ScopeData extends ScopeDataAbstract {
9
9
  if(!_self['__'+name+'__'])
10
10
  return;
11
11
 
12
- _self.__properties__.push(name);
13
12
  const _property = _self['__'+name+'__'],
14
13
  propertyType = _property[0],
15
14
  config = _property[1] || {};
package/src/Service.ts ADDED
@@ -0,0 +1,24 @@
1
+ import {ScopeData} from "./Scope/ScopeData";
2
+ import {Scope} from "./Scope";
3
+
4
+ export class Service extends ScopeData {
5
+ protected static _instance: Service;
6
+ protected _scope: Scope;
7
+
8
+ constructor() {
9
+ super();
10
+ this._scope = new Scope();
11
+ this._scope.wrap(this);
12
+ }
13
+
14
+ public get scope(): Scope {
15
+ return this._scope;
16
+ }
17
+
18
+ public static get instance(): Service {
19
+ if (!this._instance) {
20
+ this._instance = new this();
21
+ }
22
+ return this._instance;
23
+ }
24
+ }
package/src/Tag.ts CHANGED
@@ -62,15 +62,18 @@ export class Tag extends DOMObject {
62
62
  this.onEventHandlers = {};
63
63
  this.analyzeElementAttributes();
64
64
  this._state = TagState.Instantiated;
65
- if (VisionHelper.window) {
66
- if (!VisionHelper.window['Tags']) {
67
- VisionHelper.window['Tags'] = [];
68
- VisionHelper.window['Attributes'] = [];
69
- }
70
- VisionHelper.window['Tags'].push(this);
65
+ if (this.hasAttribute('slot')) {
66
+ this.addEventHandler('slotted',[], (e) => {
67
+ console.log('slot change', e, this.element.assignedSlot);
68
+ })
71
69
  }
72
70
  }
73
71
 
72
+ public slotted(slot: HTMLSlotElement) {
73
+ this.slot = slot;
74
+ console.log('i am slotted', slot);
75
+ }
76
+
74
77
  protected onAttributeStateChange(event) {
75
78
  if (event.previouseState === AttributeState.Deferred) // @todo: what is this?
76
79
  this._nonDeferredAttributes.length = 0;
@@ -6,6 +6,8 @@ import {Registry} from "../Registry";
6
6
  export class ControllerAttribute extends Attribute {
7
7
  public static readonly canDefer: boolean = false;
8
8
  public static readonly scoped: boolean = true;
9
+ public readonly registryName: string = 'controllers'
10
+ public readonly assignToParent: boolean = true;
9
11
  protected attributeKey: string;
10
12
  protected className: string;
11
13
  protected defaultClassName: string;
@@ -18,15 +20,21 @@ export class ControllerAttribute extends Attribute {
18
20
  this.attributeKey = this.getAttributeBinding();
19
21
  this.className = this.getAttributeValue(this.defaultClassName);
20
22
 
21
- const cls = await Registry.instance.controllers.get(this.className);
22
- this.instantiateClass(cls);
23
+ const cls = await Registry.instance[this.registryName].get(this.className);
24
+ const obj = this.instantiateClass(cls);
23
25
 
24
- if (this.attributeKey && parentScope)
25
- parentScope.set(this.attributeKey, this.tag.scope);
26
+ if (this.attributeKey && obj) {
27
+ if (this.assignToParent && parentScope) {
28
+ parentScope.set(this.attributeKey, obj);
29
+ } else {
30
+ this.tag.scope.set(this.attributeKey, obj);
31
+ }
32
+ }
26
33
  await super.setup();
27
34
  }
28
35
 
29
- protected instantiateClass(cls) {
36
+ protected instantiateClass(cls): any {
30
37
  this.tag.wrap(cls);
38
+ return this.tag.scope;
31
39
  }
32
40
  }
@@ -26,15 +26,15 @@ export class JSONAttribute extends Attribute {
26
26
  } else {
27
27
  json = unescape(this.getAttributeValue());
28
28
  }
29
- const property = this.getAttributeBinding();
30
29
  const data = JSON.parse(json);
30
+
31
31
  if (data && typeof data === 'object' && data.constructor === Object) {
32
32
  const newScope = new Scope(scope);
33
33
  newScope.wrap(data);
34
34
  scope.set(key, newScope);
35
+ } else {
36
+ scope.set(key, data);
35
37
  }
36
-
37
- scope.set(key, data);
38
38
  await super.extract();
39
39
  }
40
40
  }
@@ -1,5 +1,8 @@
1
1
  import {ControllerAttribute} from "./ControllerAttribute";
2
+ import {Registry} from "../Registry";
2
3
 
4
+ @Registry.attribute('vsn-model')
3
5
  export class ModelAttribute extends ControllerAttribute {
4
6
  public static readonly canDefer: boolean = false;
7
+ public readonly registryName: string = 'models'
5
8
  }
@@ -0,0 +1,13 @@
1
+ import {ControllerAttribute} from "./ControllerAttribute";
2
+ import {Registry} from "../Registry";
3
+
4
+ @Registry.attribute('vsn-service')
5
+ export class ServiceAttribute extends ControllerAttribute {
6
+ public static readonly canDefer: boolean = false;
7
+ public readonly registryName: string = 'services'
8
+ public readonly assignToParent: boolean = false;
9
+
10
+ protected instantiateClass(cls): any {
11
+ return cls.instance.scope;
12
+ }
13
+ }
@@ -21,6 +21,7 @@ export {RootAttribute} from "./RootAttribute";
21
21
  export {ScopeAttribute} from "./ScopeAttribute";
22
22
  export {ScopeChange} from "./ScopeChange";
23
23
  export {ScriptAttribute} from "./ScriptAttribute";
24
+ export {ServiceAttribute} from "./ServiceAttribute";
24
25
  export {SetAttribute} from "./SetAttribute";
25
26
  export {StandardAttribute} from "./StandardAttribute";
26
27
  export {StyleAttribute} from "./StyleAttribute";
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.1.85';
1
+ export const VERSION = '0.1.88';
2
2
 
package/src/vsn.ts CHANGED
@@ -91,6 +91,7 @@ export {ScopeReference} from './Scope/ScopeReference';
91
91
  export {WrappedArray} from './Scope/WrappedArray';
92
92
  export {Controller} from './Controller';
93
93
  export {Model} from './Model';
94
+ export {Service} from './Service';
94
95
  export {EventDispatcher} from './EventDispatcher';
95
96
  export {MessageList} from './MessageList';
96
97
  export {SimplePromise} from './SimplePromise';
@@ -3,23 +3,23 @@ import {DOM} from "../../src/DOM";
3
3
  describe('JSONAttribute', () => {
4
4
  it("vsn-json should work with script/ld-json and an array", (done) => {
5
5
  document.body.innerHTML = `
6
- <script type="application/ld+json" vsn-json:test>
6
+ <script type="application/ld+json" vsn-json:t0>
7
7
  [1,2,3,"four"]
8
8
  </script>
9
9
  `;
10
10
  const dom = new DOM(document);
11
11
  dom.once('built', async () => {
12
- expect(dom.root.scope.get('test')[0]).toBe(1);
13
- expect(dom.root.scope.get('test')[1]).toBe(2);
14
- expect(dom.root.scope.get('test')[2]).toBe(3);
15
- expect(dom.root.scope.get('test')[3]).toBe("four");
12
+ expect(dom.root.scope.get('t0')[0]).toBe(1);
13
+ expect(dom.root.scope.get('t0')[1]).toBe(2);
14
+ expect(dom.root.scope.get('t0')[2]).toBe(3);
15
+ expect(dom.root.scope.get('t0')[3]).toBe("four");
16
16
  done();
17
17
  });
18
18
  });
19
19
 
20
20
  it("vsn-json should work with script/ld-json and an object", (done) => {
21
21
  document.body.innerHTML = `
22
- <script type="application/ld+json" vsn-json:test>
22
+ <script type="application/ld+json" vsn-json:t1>
23
23
  {
24
24
  "testing": [1,2,3,"four"],
25
25
  "test": ["one","two","three",4],
@@ -29,47 +29,49 @@ describe('JSONAttribute', () => {
29
29
  `;
30
30
  const dom = new DOM(document);
31
31
  dom.once('built', async () => {
32
- expect(dom.root.scope.get('test').get("testing")[0]).toBe(1);
33
- expect(dom.root.scope.get('test').get("testing")[1]).toBe(2);
34
- expect(dom.root.scope.get('test').get("testing")[2]).toBe(3);
35
- expect(dom.root.scope.get('test').get("testing")[3]).toBe("four");
36
- expect(dom.root.scope.get('test').get("test")[0]).toBe("one");
37
- expect(dom.root.scope.get('test').get("test")[1]).toBe("two");
38
- expect(dom.root.scope.get('test').get("test")[2]).toBe("three");
39
- expect(dom.root.scope.get('test').get("test")[3]).toBe(4);
40
- expect(dom.root.scope.get('test').get("val")).toBe(111);
32
+ expect(dom.root.scope.get('t1').get("testing")[0]).toBe(1);
33
+ expect(dom.root.scope.get('t1').get("testing")[1]).toBe(2);
34
+ expect(dom.root.scope.get('t1').get("testing")[2]).toBe(3);
35
+ expect(dom.root.scope.get('t1').get("testing")[3]).toBe("four");
36
+ expect(dom.root.scope.get('t1').get("test")[0]).toBe("one");
37
+ expect(dom.root.scope.get('t1').get("test")[1]).toBe("two");
38
+ expect(dom.root.scope.get('t1').get("test")[2]).toBe("three");
39
+ expect(dom.root.scope.get('t1').get("test")[3]).toBe(4);
40
+ expect(dom.root.scope.get('t1').get("val")).toBe(111);
41
41
  done();
42
42
  });
43
43
  });
44
44
 
45
45
  it("vsn-json should work with div and an array", (done) => {
46
46
  document.body.innerHTML = `
47
- <div vsn-json:test="[1,2,3,&quot;four&quot;]"></div>
47
+ <div vsn-json:t2="[1,2,3,&quot;four&quot;]"></div>
48
48
  `;
49
+
49
50
  const dom = new DOM(document);
50
51
  dom.once('built', async () => {
51
- expect(dom.root.scope.get('test')[0]).toBe(1);
52
- expect(dom.root.scope.get('test')[1]).toBe(2);
53
- expect(dom.root.scope.get('test')[2]).toBe(3);
54
- expect(dom.root.scope.get('test')[3]).toBe("four");
52
+ console.log('scope keys', dom.root.scope.keys);
53
+ expect(dom.root.scope.get('t2')[0]).toBe(1);
54
+ expect(dom.root.scope.get('t2')[1]).toBe(2);
55
+ expect(dom.root.scope.get('t2')[2]).toBe(3);
56
+ expect(dom.root.scope.get('t2')[3]).toBe("four");
55
57
  done();
56
58
  });
57
59
  });
58
60
 
59
61
  it("vsn-json should work with div and an object", (done) => {
60
62
  document.body.innerHTML = `
61
- <div vsn-json:test="{&quot;testing&quot;: [1,2,3,&quot;four&quot;],&quot;test&quot;: [&quot;one&quot;,&quot;two&quot;,&quot;three&quot;,4]}"></div>
63
+ <div vsn-json:t3="{&quot;testing&quot;: [1,2,3,&quot;four&quot;],&quot;test&quot;: [&quot;one&quot;,&quot;two&quot;,&quot;three&quot;,4]}"></div>
62
64
  `;
63
65
  const dom = new DOM(document);
64
66
  dom.once('built', async () => {
65
- expect(dom.root.scope.get('test').get("testing")[0]).toBe(1);
66
- expect(dom.root.scope.get('test').get("testing")[1]).toBe(2);
67
- expect(dom.root.scope.get('test').get("testing")[2]).toBe(3);
68
- expect(dom.root.scope.get('test').get("testing")[3]).toBe("four");
69
- expect(dom.root.scope.get('test').get("test")[0]).toBe("one");
70
- expect(dom.root.scope.get('test').get("test")[1]).toBe("two");
71
- expect(dom.root.scope.get('test').get("test")[2]).toBe("three");
72
- expect(dom.root.scope.get('test').get("test")[3]).toBe(4);
67
+ expect(dom.root.scope.get('t3').get("testing")[0]).toBe(1);
68
+ expect(dom.root.scope.get('t3').get("testing")[1]).toBe(2);
69
+ expect(dom.root.scope.get('t3').get("testing")[2]).toBe(3);
70
+ expect(dom.root.scope.get('t3').get("testing")[3]).toBe("four");
71
+ expect(dom.root.scope.get('t3').get("test")[0]).toBe("one");
72
+ expect(dom.root.scope.get('t3').get("test")[1]).toBe("two");
73
+ expect(dom.root.scope.get('t3').get("test")[2]).toBe("three");
74
+ expect(dom.root.scope.get('t3').get("test")[3]).toBe(4);
73
75
  done();
74
76
  });
75
77
  });
@@ -0,0 +1,34 @@
1
+ import {DOM} from "../../src/DOM";
2
+ import "../../src/Types";
3
+ import "../../src/attributes/_imports";
4
+ import {Registry} from "../../src/Registry";
5
+ import {Service} from "../../src/Service";
6
+ import {property} from "../../src/Scope/properties/Property";
7
+
8
+
9
+ @Registry.service('TestService')
10
+ class TestService extends Service {
11
+ @property()
12
+ public test: string;
13
+
14
+ constructor() {
15
+ super();
16
+ }
17
+
18
+ }
19
+
20
+
21
+ describe('ServiceAttribute', () => {
22
+ it("vsn-styles to just work", (done) => {
23
+ document.body.innerHTML = `
24
+ <div vsn-service:test1="TestService" id="test"></div>
25
+ <div vsn-service:test2="TestService" vsn-set:test2.test="testing"></div>
26
+ `;
27
+ const dom = new DOM(document);
28
+ dom.once('built', async () => {
29
+ expect(TestService.instance.test).toBe('testing');
30
+ expect(await dom.exec('#test.test1.test')).toBe('testing');
31
+ done();
32
+ });
33
+ });
34
+ });