@microsoft/fast-html 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (68) hide show
  1. package/README.md +266 -19
  2. package/dist/dts/components/element.d.ts +10 -0
  3. package/dist/dts/components/index.d.ts +3 -1
  4. package/dist/dts/components/observer-map.d.ts +27 -0
  5. package/dist/dts/components/schema.d.ts +144 -0
  6. package/dist/dts/components/template.d.ts +83 -7
  7. package/dist/dts/components/utilities.d.ts +128 -37
  8. package/dist/dts/index.d.ts +1 -1
  9. package/dist/dts/tsdoc-metadata.json +1 -1
  10. package/dist/esm/components/element.js +73 -0
  11. package/dist/esm/components/index.js +3 -1
  12. package/dist/esm/components/observer-map.js +68 -0
  13. package/dist/esm/components/observer-map.spec.js +39 -0
  14. package/dist/esm/components/schema.js +250 -0
  15. package/dist/esm/components/schema.spec.js +484 -0
  16. package/dist/esm/components/template.js +242 -213
  17. package/dist/esm/components/utilities.js +1008 -64
  18. package/dist/esm/components/utilities.spec.js +522 -93
  19. package/dist/esm/index.js +1 -1
  20. package/dist/fast-html.api.json +350 -1
  21. package/dist/fast-html.d.ts +283 -6
  22. package/dist/fast-html.untrimmed.d.ts +283 -6
  23. package/package.json +27 -38
  24. package/rules/attribute-directives.yml +38 -0
  25. package/rules/call-expression-with-event-argument.yml +41 -0
  26. package/rules/member-expression.yml +33 -0
  27. package/rules/tag-function-to-template-literal.yml +16 -0
  28. package/dist/dts/fixtures/binding/binding.spec.d.ts +0 -1
  29. package/dist/dts/fixtures/binding/main.d.ts +0 -1
  30. package/dist/dts/fixtures/children/children.spec.d.ts +0 -1
  31. package/dist/dts/fixtures/children/main.d.ts +0 -1
  32. package/dist/dts/fixtures/dot-syntax/dot-syntax.spec.d.ts +0 -1
  33. package/dist/dts/fixtures/dot-syntax/main.d.ts +0 -1
  34. package/dist/dts/fixtures/event/event.spec.d.ts +0 -1
  35. package/dist/dts/fixtures/event/main.d.ts +0 -1
  36. package/dist/dts/fixtures/partial/main.d.ts +0 -1
  37. package/dist/dts/fixtures/partial/partial.spec.d.ts +0 -1
  38. package/dist/dts/fixtures/ref/main.d.ts +0 -1
  39. package/dist/dts/fixtures/ref/ref.spec.d.ts +0 -1
  40. package/dist/dts/fixtures/repeat/main.d.ts +0 -1
  41. package/dist/dts/fixtures/repeat/repeat.spec.d.ts +0 -1
  42. package/dist/dts/fixtures/slotted/main.d.ts +0 -1
  43. package/dist/dts/fixtures/slotted/slotted.spec.d.ts +0 -1
  44. package/dist/dts/fixtures/when/main.d.ts +0 -1
  45. package/dist/dts/fixtures/when/when.spec.d.ts +0 -1
  46. package/dist/esm/fixtures/attribute/attribute.spec.js +0 -23
  47. package/dist/esm/fixtures/attribute/main.js +0 -19
  48. package/dist/esm/fixtures/binding/binding.spec.js +0 -17
  49. package/dist/esm/fixtures/binding/main.js +0 -19
  50. package/dist/esm/fixtures/children/children.spec.js +0 -33
  51. package/dist/esm/fixtures/children/main.js +0 -24
  52. package/dist/esm/fixtures/dot-syntax/dot-syntax.spec.js +0 -9
  53. package/dist/esm/fixtures/dot-syntax/main.js +0 -16
  54. package/dist/esm/fixtures/event/event.spec.js +0 -12
  55. package/dist/esm/fixtures/event/main.js +0 -16
  56. package/dist/esm/fixtures/partial/main.js +0 -31
  57. package/dist/esm/fixtures/partial/partial.spec.js +0 -14
  58. package/dist/esm/fixtures/ref/main.js +0 -14
  59. package/dist/esm/fixtures/ref/ref.spec.js +0 -13
  60. package/dist/esm/fixtures/repeat/main.js +0 -19
  61. package/dist/esm/fixtures/repeat/repeat.spec.js +0 -26
  62. package/dist/esm/fixtures/slotted/main.js +0 -22
  63. package/dist/esm/fixtures/slotted/slotted.spec.js +0 -25
  64. package/dist/esm/fixtures/when/main.js +0 -146
  65. package/dist/esm/fixtures/when/when.spec.js +0 -82
  66. package/dist/esm/tsconfig.tsbuildinfo +0 -1
  67. /package/dist/dts/{fixtures/attribute/attribute.spec.d.ts → components/observer-map.spec.d.ts} +0 -0
  68. /package/dist/dts/{fixtures/attribute/main.d.ts → components/schema.spec.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/fast-html",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.41",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Microsoft",
@@ -11,42 +11,35 @@
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/Microsoft/fast.git",
14
- "directory": "packages/web-components/fast-html"
14
+ "directory": "packages/fast-html"
15
15
  },
16
16
  "bugs": {
17
17
  "url": "https://github.com/Microsoft/fast/issues/new/choose"
18
18
  },
19
19
  "files": [
20
- "./dist"
20
+ "./dist",
21
+ "./rules/*.yml"
21
22
  ],
22
23
  "scripts": {
23
- "clean": "tsc -b --clean src",
24
- "clean:dist": "node ../../../build/clean.js dist",
25
- "build": "tsc -b src && npm run doc",
26
- "build:attribute": "webpack --config ./src/fixtures/attribute/webpack.config.js",
27
- "build:event": "webpack --config ./src/fixtures/event/webpack.config.js",
28
- "build:binding": "webpack --config ./src/fixtures/binding/webpack.config.js",
29
- "build:children": "webpack --config ./src/fixtures/children/webpack.config.js",
30
- "build:dot-syntax": "webpack --config ./src/fixtures/dot-syntax/webpack.config.js",
31
- "build:partial": "webpack --config ./src/fixtures/partial/webpack.config.js",
32
- "build:when": "webpack --config ./src/fixtures/when/webpack.config.js",
33
- "build:ref": "webpack --config ./src/fixtures/ref/webpack.config.js",
34
- "build:repeat": "webpack --config ./src/fixtures/repeat/webpack.config.js",
35
- "build:slotted": "webpack --config ./src/fixtures/slotted/webpack.config.js",
36
- "build-app": "npm run build:attribute && npm run build:dot-syntax && npm run build:partial && npm run build:event && npm run build:children && npm run build:binding && npm run build:when && npm run build:ref && npm run build:repeat && npm run build:slotted",
37
- "build-server": "tsc -b server",
38
- "doc": "api-extractor run --local",
24
+ "build:tsc": "tsc -p ./tsconfig.json",
25
+ "build": "npm run build:tsc && npm run doc",
26
+ "clean": "rimraf dist temp test-results",
27
+ "dev:full": "concurrently -k -n fast-element,fast-html,server \"npm run dev --workspace=@microsoft/fast-element\" \"npm:watch\" \"npm:test-server\"",
28
+ "dev": "concurrently -k -n tsc,server \"npm run watch\" \"npm run test-server\"",
39
29
  "doc:ci": "api-extractor run",
30
+ "doc": "npm run doc:ci -- --local",
31
+ "eslint:fix": "npm run eslint -- --fix",
40
32
  "eslint": "eslint . --ext .ts",
41
- "eslint:fix": "eslint . --ext .ts --fix",
42
- "prepublishOnly": "npm run clean && npm run build",
43
- "pretest": "npm run build && npm run build-server",
44
- "prettier:diff": "prettier --config ../../../.prettierrc \"**/*.{ts,html}\" --list-different",
45
- "prettier": "prettier --config ../../../.prettierrc --write \"**/*.{ts,html}\"",
46
- "test": "npm run build-app && playwright test --config=playwright.config.cjs",
47
- "test-server": "node server/dist/server.js",
48
33
  "install-playwright-browsers": "npm run playwright install",
49
- "dev": "npm run build && npm run build-app && npm run build-server && npm run test-server"
34
+ "prepublishOnly": "npm run clean && npm run build",
35
+ "prettier:diff": "prettier --config ../../.prettierrc \"**/*.{ts,html}\" --list-different",
36
+ "prettier": "prettier --config ../../.prettierrc --write \"**/*.{ts,html}\"",
37
+ "test-server": "npx vite test/ --clearScreen false",
38
+ "test:playwright": "playwright test",
39
+ "test:rules": "sg test --skip-snapshot-tests",
40
+ "test": "npm run test:playwright && npm run test:rules",
41
+ "test:ui": "concurrently -k -n fast-element,fast-html,playwright \"npm run dev --workspace=@microsoft/fast-element\" \"npm:watch\" \"npx playwright test --ui\"",
42
+ "watch": "npm run build:tsc -- -w --preserveWatchOutput"
50
43
  },
51
44
  "description": "A package for facilitating rendering FAST Web Components in a non-browser environment.",
52
45
  "exports": {
@@ -54,25 +47,21 @@
54
47
  "types": "./dist/dts/index.d.ts",
55
48
  "default": "./dist/esm/index.js"
56
49
  },
50
+ "./utilities.js": {
51
+ "types": "./dist/dts/components/utilities.d.ts",
52
+ "default": "./dist/esm/components/utilities.js"
53
+ },
54
+ "./rules/*.yml": "./rules/*.yml",
57
55
  "./package.json": "./package.json"
58
56
  },
59
57
  "sideEffects": [
60
58
  "./dist/esm/index.js"
61
59
  ],
62
60
  "peerDependencies": {
63
- "@microsoft/fast-element": "^2.2.0"
61
+ "@microsoft/fast-element": "^2.10.2"
64
62
  },
65
63
  "devDependencies": {
66
- "@microsoft/api-extractor": "^7.47.0",
67
- "@microsoft/fast-element": "^2.2.0",
68
- "@playwright/test": "^1.49.0",
69
- "@types/express": "^4.17.21",
70
- "@types/node": "^17.0.17",
71
- "express": "^4.19.2",
72
- "typescript": "~5.3.0",
73
- "webpack": "^5.97.1",
74
- "webpack-cli": "^6.0.1",
75
- "webpack-merge": "^6.0.1"
64
+ "@microsoft/fast-element": "^2.10.2"
76
65
  },
77
66
  "beachball": {
78
67
  "disallowedChangeTypes": [
@@ -0,0 +1,38 @@
1
+ # https://ast-grep.github.io/guide/rule-config.html#rule
2
+ # from: ${ref("defaultSlot")}
3
+ # to: f-ref="{defaultSlot}"
4
+ id: binding - convert attribute directives
5
+ language: typescript
6
+ utils:
7
+ call-expression:
8
+ has:
9
+ nthChild: 1
10
+ kind: call_expression
11
+ all:
12
+ - matches: identifier
13
+ - matches: arguments
14
+ identifier:
15
+ has:
16
+ nthChild: 1
17
+ kind: identifier
18
+ pattern: $DIRECTIVE
19
+ arguments:
20
+ has:
21
+ kind: arguments
22
+ matches: string
23
+ string:
24
+ has:
25
+ kind: string
26
+ matches: string-fragment
27
+ string-fragment:
28
+ has:
29
+ kind: string_fragment
30
+ pattern: $STRING
31
+ constraints:
32
+ DIRECTIVE:
33
+ regex: ref|slotted|children
34
+ rule:
35
+ kind: template_substitution
36
+ matches: call-expression
37
+ fix:
38
+ 'f-$DIRECTIVE="{$STRING}"'
@@ -0,0 +1,41 @@
1
+ # https://ast-grep.github.io/guide/rule-config.html#rule
2
+ # from: ${(x, c) => x.foo(c.event)}
3
+ # to: {foo(event)}
4
+ id: binding - convert call expression with event argument
5
+ language: typescript
6
+ utils:
7
+ arrow-function:
8
+ has:
9
+ kind: arrow_function
10
+ matches: call-expression
11
+ call-expression:
12
+ has:
13
+ kind: call_expression
14
+ all:
15
+ - matches: handler-arguments
16
+ - matches: handler-expression
17
+ handler-expression:
18
+ has:
19
+ kind: member_expression
20
+ matches: handler-expression-property
21
+ handler-expression-property:
22
+ has:
23
+ kind: property_identifier
24
+ pattern: $A
25
+ handler-arguments:
26
+ has:
27
+ kind: arguments
28
+ matches: handler-arguments-member-expression
29
+ handler-arguments-member-expression:
30
+ has:
31
+ kind: member_expression
32
+ matches: handler-arguments-property-identifier
33
+ handler-arguments-property-identifier:
34
+ has:
35
+ kind: property_identifier
36
+ pattern: $B
37
+ rule:
38
+ kind: template_substitution
39
+ matches: arrow-function
40
+ fix:
41
+ '{$A($B)}'
@@ -0,0 +1,33 @@
1
+ # https://ast-grep.github.io/guide/rule-config.html#rule
2
+ # from: ${x => x.foo}
3
+ # to: {{foo}}
4
+ id: binding - convert member expression
5
+ language: typescript
6
+ utils:
7
+ arrow-function:
8
+ has:
9
+ kind: arrow_function
10
+ all:
11
+ - matches: identifier
12
+ - matches: member-expression
13
+ member-expression:
14
+ has:
15
+ kind: member_expression
16
+ nthChild: 2
17
+ all:
18
+ - matches: identifier
19
+ - matches: property-identifier
20
+ identifier:
21
+ has:
22
+ kind: identifier
23
+ nthChild: 1
24
+ property-identifier:
25
+ has:
26
+ kind: property_identifier
27
+ nthChild: 2
28
+ pattern: $A
29
+ rule:
30
+ kind: template_substitution
31
+ matches: arrow-function
32
+ fix:
33
+ '{{$A}}'
@@ -0,0 +1,16 @@
1
+ # https://ast-grep.github.io/guide/rule-config.html#rule
2
+ # from: export const template = html`<slot></slot>`
3
+ # to: `<slot></slot>`
4
+ id: convert tag function to template literal
5
+ language: typescript
6
+ utils:
7
+ is-tag-template:
8
+ has:
9
+ kind: template_string
10
+ pattern: $B
11
+ rule:
12
+ kind: call_expression
13
+ matches: is-tag-template
14
+ pattern: $A
15
+ fix:
16
+ '$B'
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { expect, test } from "@playwright/test";
3
- test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create a non-binding attribute", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield page.goto("/attribute");
6
- const customElement = page.locator("test-element");
7
- const customElementInput = customElement.locator("input");
8
- yield expect(customElementInput).toHaveAttribute("disabled");
9
- }));
10
- test("create an attribute binding", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
11
- yield page.goto("/attribute");
12
- const customElement = page.locator("test-element");
13
- yield expect(customElement).toHaveAttribute("type", "checkbox");
14
- yield expect(customElement.locator("input[type='checkbox']")).toHaveCount(1);
15
- yield page.evaluate(() => {
16
- var _a;
17
- const customElement = document.getElementsByTagName("test-element");
18
- (_a = customElement.item(0)) === null || _a === void 0 ? void 0 : _a.setAttribute("type", "radio");
19
- });
20
- yield expect(customElement).toHaveAttribute("type", "radio");
21
- yield expect(customElement.locator("input[type='radio']")).toHaveCount(1);
22
- }));
23
- }));
@@ -1,19 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { TemplateElement } from "@microsoft/fast-html";
3
- import { attr, FASTElement } from "@microsoft/fast-element";
4
- class TestElement extends FASTElement {
5
- constructor() {
6
- super(...arguments);
7
- this.type = "radio";
8
- }
9
- }
10
- __decorate([
11
- attr,
12
- __metadata("design:type", String)
13
- ], TestElement.prototype, "type", void 0);
14
- TestElement.define({
15
- name: "test-element",
16
- });
17
- TemplateElement.define({
18
- name: "f-template",
19
- });
@@ -1,17 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { expect, test } from "@playwright/test";
3
- test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create a binding", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield page.goto("/binding");
6
- const customElement = yield page.locator("test-element");
7
- yield expect(yield customElement.getAttribute("text")).toEqual("Hello world");
8
- yield expect(customElement).toHaveText("Hello world");
9
- yield page.evaluate(() => {
10
- var _a;
11
- const customElement = document.getElementsByTagName("test-element");
12
- (_a = customElement.item(0)) === null || _a === void 0 ? void 0 : _a.setAttribute("text", "Hello pluto");
13
- });
14
- yield expect(yield customElement.getAttribute("text")).toEqual("Hello pluto");
15
- yield expect(customElement).toHaveText("Hello pluto");
16
- }));
17
- }));
@@ -1,19 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { TemplateElement } from "@microsoft/fast-html";
3
- import { attr, FASTElement } from "@microsoft/fast-element";
4
- class TestElement extends FASTElement {
5
- constructor() {
6
- super(...arguments);
7
- this.text = "Hello";
8
- }
9
- }
10
- __decorate([
11
- attr,
12
- __metadata("design:type", String)
13
- ], TestElement.prototype, "text", void 0);
14
- TestElement.define({
15
- name: "test-element",
16
- });
17
- TemplateElement.define({
18
- name: "f-template",
19
- });
@@ -1,33 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { expect, test } from "@playwright/test";
3
- test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create a children directive", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield page.goto("/children");
6
- const listItemCount1 = yield page.evaluate(() => {
7
- var _a;
8
- const customElement = document.getElementsByTagName("test-element");
9
- const listItems = (_a = customElement.item(0)) === null || _a === void 0 ? void 0 : _a.listItems.filter((listItem) => {
10
- return listItem instanceof HTMLLIElement;
11
- });
12
- return listItems === null || listItems === void 0 ? void 0 : listItems.length;
13
- });
14
- expect(listItemCount1).toEqual(2);
15
- yield page.evaluate(() => {
16
- const customElement = document.getElementsByTagName("test-element");
17
- customElement.item(0).list = [
18
- "A",
19
- "B",
20
- "C"
21
- ];
22
- });
23
- const listItemCount2 = yield page.evaluate(() => {
24
- var _a;
25
- const customElement = document.getElementsByTagName("test-element");
26
- const listItems = (_a = customElement.item(0)) === null || _a === void 0 ? void 0 : _a.listItems.filter((listItem) => {
27
- return listItem instanceof HTMLLIElement;
28
- });
29
- return listItems === null || listItems === void 0 ? void 0 : listItems.length;
30
- });
31
- expect(listItemCount2).toEqual(3);
32
- }));
33
- }));
@@ -1,24 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { TemplateElement } from "@microsoft/fast-html";
3
- import { FASTElement, observable } from "@microsoft/fast-element";
4
- class TestElement extends FASTElement {
5
- constructor() {
6
- super(...arguments);
7
- this.listItems = [];
8
- this.list = ["Foo", "Bar"];
9
- }
10
- }
11
- __decorate([
12
- observable,
13
- __metadata("design:type", Array)
14
- ], TestElement.prototype, "listItems", void 0);
15
- __decorate([
16
- observable,
17
- __metadata("design:type", Array)
18
- ], TestElement.prototype, "list", void 0);
19
- TestElement.define({
20
- name: "test-element",
21
- });
22
- TemplateElement.define({
23
- name: "f-template",
24
- });
@@ -1,9 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { expect, test } from "@playwright/test";
3
- test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create a object property reference using dot syntax in a binding", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield page.goto("/dot-syntax");
6
- const customElement = yield page.locator("test-element");
7
- yield expect(customElement).toHaveText("bar");
8
- }));
9
- }));
@@ -1,16 +0,0 @@
1
- import { TemplateElement } from "@microsoft/fast-html";
2
- import { FASTElement } from "@microsoft/fast-element";
3
- class TestElement extends FASTElement {
4
- constructor() {
5
- super(...arguments);
6
- this.object = {
7
- foo: "bar",
8
- };
9
- }
10
- }
11
- TestElement.define({
12
- name: "test-element",
13
- });
14
- TemplateElement.define({
15
- name: "f-template",
16
- });
@@ -1,12 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { expect, test } from "@playwright/test";
3
- test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create an event attribute", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield page.goto("/event");
6
- const customElement = yield page.locator("test-element");
7
- let msgCount = 0;
8
- yield page.on("console", msg => msgCount++);
9
- yield customElement.locator("button").click();
10
- expect(msgCount).toEqual(1);
11
- }));
12
- }));
@@ -1,16 +0,0 @@
1
- import { TemplateElement } from "@microsoft/fast-html";
2
- import { FASTElement } from "@microsoft/fast-element";
3
- class TestElement extends FASTElement {
4
- constructor() {
5
- super(...arguments);
6
- this.handleClick = () => {
7
- console.log("click!");
8
- };
9
- }
10
- }
11
- TestElement.define({
12
- name: "test-element",
13
- });
14
- TemplateElement.define({
15
- name: "f-template",
16
- });
@@ -1,31 +0,0 @@
1
- import { TemplateElement } from "@microsoft/fast-html";
2
- import { FASTElement } from "@microsoft/fast-element";
3
- class TestElement extends FASTElement {
4
- constructor() {
5
- super(...arguments);
6
- this.items = [
7
- {
8
- text: "Hello",
9
- },
10
- {
11
- text: "Earth",
12
- items: [
13
- {
14
- text: "Pluto",
15
- items: [
16
- {
17
- text: "Mars",
18
- },
19
- ],
20
- },
21
- ],
22
- },
23
- ];
24
- }
25
- }
26
- TestElement.define({
27
- name: "test-element",
28
- });
29
- TemplateElement.define({
30
- name: "f-template",
31
- });
@@ -1,14 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { expect, test } from "@playwright/test";
3
- test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create a partial", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield page.goto("/partial");
6
- const customElement = yield page.locator("#test");
7
- let customElementListItems = yield customElement.locator("li");
8
- expect(yield customElementListItems.count()).toEqual(4);
9
- expect(yield customElementListItems.nth(0).textContent()).toEqual("Hello");
10
- expect(yield customElementListItems.nth(1).textContent()).toContain("Earth");
11
- expect(yield customElementListItems.nth(2).textContent()).toContain("Pluto");
12
- expect(yield customElementListItems.nth(3).textContent()).toContain("Mars");
13
- }));
14
- }));
@@ -1,14 +0,0 @@
1
- import { TemplateElement } from "@microsoft/fast-html";
2
- import { FASTElement } from "@microsoft/fast-element";
3
- class TestElement extends FASTElement {
4
- constructor() {
5
- super(...arguments);
6
- this.video = null;
7
- }
8
- }
9
- TestElement.define({
10
- name: "test-element",
11
- });
12
- TemplateElement.define({
13
- name: "f-template",
14
- });
@@ -1,13 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { expect, test } from "@playwright/test";
3
- test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create a ref directive", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield page.goto("/ref");
6
- const isVideo = yield page.evaluate(() => {
7
- var _a;
8
- const customElement = document.getElementsByTagName("test-element");
9
- return ((_a = customElement.item(0)) === null || _a === void 0 ? void 0 : _a.video) instanceof HTMLVideoElement;
10
- });
11
- expect(isVideo).toEqual(true);
12
- }));
13
- }));
@@ -1,19 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { TemplateElement } from "@microsoft/fast-html";
3
- import { FASTElement, observable } from "@microsoft/fast-element";
4
- class TestElement extends FASTElement {
5
- constructor() {
6
- super(...arguments);
7
- this.list = ["Foo", "Bar"];
8
- }
9
- }
10
- __decorate([
11
- observable,
12
- __metadata("design:type", Array)
13
- ], TestElement.prototype, "list", void 0);
14
- TestElement.define({
15
- name: "test-element",
16
- });
17
- TemplateElement.define({
18
- name: "f-template",
19
- });
@@ -1,26 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { expect, test } from "@playwright/test";
3
- test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create a repeat directive", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
- yield page.goto("/repeat");
6
- const customElement = yield page.locator("test-element");
7
- let customElementListItems = yield customElement.locator("li");
8
- expect(yield customElementListItems.count()).toEqual(2);
9
- expect(yield customElementListItems.nth(0).textContent()).toEqual("Foo");
10
- expect(yield customElementListItems.nth(1).textContent()).toEqual("Bar");
11
- yield page.evaluate(() => {
12
- const customElement = document.getElementsByTagName("test-element");
13
- customElement.item(0).list = [
14
- "A",
15
- "B",
16
- "C"
17
- ];
18
- });
19
- yield expect(customElement).toHaveJSProperty("list", ["A", "B", "C"]);
20
- customElementListItems = yield customElement.locator("li");
21
- expect(yield customElementListItems.count()).toEqual(3);
22
- expect(yield customElementListItems.nth(0).textContent()).toEqual("A");
23
- expect(yield customElementListItems.nth(1).textContent()).toEqual("B");
24
- expect(yield customElementListItems.nth(2).textContent()).toEqual("C");
25
- }));
26
- }));
@@ -1,22 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { TemplateElement } from "@microsoft/fast-html";
3
- import { FASTElement, observable } from "@microsoft/fast-element";
4
- class TestElement extends FASTElement {
5
- constructor() {
6
- super(...arguments);
7
- this.slottedNodes = [];
8
- }
9
- slottedNodesChanged() {
10
- this.classList.add(`class-${this.slottedNodes.length}`);
11
- }
12
- }
13
- __decorate([
14
- observable,
15
- __metadata("design:type", Array)
16
- ], TestElement.prototype, "slottedNodes", void 0);
17
- TestElement.define({
18
- name: "test-element",
19
- });
20
- TemplateElement.define({
21
- name: "f-template",
22
- });