acrylblends 0.6.3 → 0.7.0
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/README.md +4 -3
- package/docs/framework/README.md +2 -2
- package/docs/framework/UPSTREAM.md +1 -1
- package/docs/framework/guides/jsx.md +51 -1
- package/docs/framework/helpers/ssg.md +3 -6
- package/docs/framework/middleware/builtin/jsx-renderer.md +0 -3
- package/docs/framework/upstream.json +2 -2
- package/lib/accepts.d.ts +1 -1
- package/lib/acryl-base.d.ts +1 -1
- package/lib/adapter.d.ts +1 -1
- package/lib/{app-wFwpg-bt.d.ts → app-D8riatvv.d.ts} +1 -1
- package/lib/{base-ddiVmiE7.js → base-NSN_SNv-.js} +1 -0
- package/lib/basic-auth.d.ts +1 -1
- package/lib/bearer-auth.d.ts +1 -1
- package/lib/body-limit.d.ts +1 -1
- package/lib/cache.d.ts +1 -1
- package/lib/cache.js +4 -4
- package/lib/{client-BHTr318g.js → client-DDLXwhBo.js} +2 -125
- package/lib/client.d.ts +2 -2
- package/lib/client.js +2 -1
- package/lib/combine.d.ts +1 -1
- package/lib/{components-DYZdxJIJ.js → components-JXVm45kK.js} +1 -1
- package/lib/{components-Ce5FRyHU.js → components-cEW3ovK0.js} +3 -3
- package/lib/compress.d.ts +1 -1
- package/lib/conninfo.d.ts +2 -2
- package/lib/{context-DVQBjuns.d.ts → context-DS3fYyG-.d.ts} +1 -1
- package/lib/context-storage.d.ts +1 -1
- package/lib/cookie.d.ts +1 -1
- package/lib/cors.d.ts +1 -1
- package/lib/csrf.d.ts +1 -1
- package/lib/dev.d.ts +2 -2
- package/lib/etag.d.ts +1 -1
- package/lib/factory.d.ts +2 -2
- package/lib/{hooks-Bq5q9IMl.js → hooks-w72iLeFR.js} +6 -6
- package/lib/{index-CUTfU69R.d.ts → index-Bb7YJKCq.d.ts} +2 -2
- package/lib/{index-CsvB-F9j.d.ts → index-BvFh1Gfx.d.ts} +1 -1
- package/lib/{index-Cqcdluyn.d.ts → index-CTy4N7ng.d.ts} +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/ip-restriction.d.ts +2 -2
- package/lib/jsx/dom/client.js +1 -1
- package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
- package/lib/jsx/dom/jsx-runtime.js +1 -1
- package/lib/jsx/dom/server.js +2 -2
- package/lib/jsx/dom.js +4 -4
- package/lib/jsx/jsx-dev-runtime.js +1 -1
- package/lib/jsx/jsx-runtime.js +1 -1
- package/lib/jsx/streaming.js +1 -1
- package/lib/{jsx-dev-runtime-kAhR_4C7.js → jsx-dev-runtime-CWLRA2F3.js} +2 -2
- package/lib/jsx-renderer.d.ts +75 -0
- package/lib/jsx-renderer.js +99 -0
- package/lib/jsx.js +4 -4
- package/lib/jwk.d.ts +1 -1
- package/lib/jwt.d.ts +1 -1
- package/lib/language.d.ts +1 -1
- package/lib/logger.d.ts +1 -1
- package/lib/loopback-only.d.ts +1 -1
- package/lib/method-not-allowed.d.ts +2 -2
- package/lib/method-override.d.ts +2 -2
- package/lib/mount.d.ts +1 -1
- package/lib/node-server/conninfo.d.ts +1 -1
- package/lib/node-server/register.d.ts +1 -0
- package/lib/node-server/register.js +73 -0
- package/lib/node-server/serve-static.d.ts +1 -1
- package/lib/node-server/serve-static.js +1 -1
- package/lib/node-server.d.ts +1 -1
- package/lib/node-server.js +1 -1
- package/lib/powered-by.d.ts +1 -1
- package/lib/pretty-json.d.ts +1 -1
- package/lib/quick.d.ts +1 -1
- package/lib/request-id.d.ts +1 -1
- package/lib/request.d.ts +1 -1
- package/lib/route.d.ts +1 -1
- package/lib/schema-validator.d.ts +1 -1
- package/lib/secure-headers.d.ts +1 -1
- package/lib/{serve-static-Cw23shXv.js → serve-static-B14MF1Va.js} +1 -0
- package/lib/serve-static.d.ts +1 -1
- package/lib/ssg-BwjcA-Ge.js +389 -0
- package/lib/ssg.d.ts +156 -0
- package/lib/ssg.js +2 -0
- package/lib/streaming.d.ts +1 -1
- package/lib/testing.d.ts +3 -3
- package/lib/testing.js +1 -1
- package/lib/timeout.d.ts +1 -1
- package/lib/timing.d.ts +1 -1
- package/lib/tiny.d.ts +1 -1
- package/lib/trailing-slash.d.ts +1 -1
- package/lib/{types-nEL8VPDC.d.ts → types-Dv_nV2cv.d.ts} +1 -1
- package/lib/{types-CQiGmsWW.d.ts → types-zNxyEpG2.d.ts} +2 -2
- package/lib/types.d.ts +1 -1
- package/lib/utils/body.d.ts +1 -1
- package/lib/utils/ipaddr.d.ts +1 -1
- package/lib/utils-Cx61GFMC.js +125 -0
- package/lib/validator.d.ts +1 -1
- package/lib/ws.d.ts +1 -1
- package/package.json +13 -1
- package/plugins/acryl-inspect/upstream.json +1 -1
- package/plugins/acryl-node-server/src/register.ts +86 -0
- package/plugins/acryl-node-server/upstream.json +5 -3
- package/plugins/acryl-router/src/core/helper/ssg/index.ts +14 -0
- package/plugins/acryl-router/src/core/helper/ssg/middleware.ts +83 -0
- package/plugins/acryl-router/src/core/helper/ssg/plugins.ts +72 -0
- package/plugins/acryl-router/src/core/helper/ssg/ssg.ts +471 -0
- package/plugins/acryl-router/src/core/helper/ssg/utils.ts +118 -0
- package/plugins/acryl-router/src/core/jsx/dom/render.ts +6 -6
- package/plugins/acryl-router/src/core/middleware/cache/index.ts +4 -4
- package/plugins/acryl-router/src/core/middleware/jsx-renderer/index.ts +162 -0
- package/plugins/acryl-router/src/helpers/index.ts +1 -0
- package/plugins/acryl-router/src/middleware/index.ts +1 -0
- package/plugins/acryl-router/upstream.json +2 -2
- package/plugins/acryl-router-http/upstream.json +1 -1
- package/plugins/acryl-state/upstream.json +1 -1
- package/plugins/desktop/main.ts +4 -1
- package/plugins/desktop/upstream.json +1 -1
- package/plugins/desktop-web/main.ts +3 -1
- package/plugins/desktop-web/upstream.json +1 -1
- package/plugins/extensions/resolve.ts +4 -0
- package/shared/AGENTS.core.md +3 -0
- package/templates/agent/package.json +7 -3
- package/templates/agent/tsconfig.json +10 -2
- package/templates/blank/package.json +7 -3
- package/templates/blank/src/about.tsx +14 -0
- package/templates/blank/src/routes.ts +2 -0
- package/templates/blank/test/app.test.ts +15 -0
- package/templates/blank/tsconfig.json +3 -1
- package/templates/todo/package.json +7 -3
- package/templates/todo/tsconfig.json +3 -1
- package/templates/todo/upstream.json +1 -1
- package/plugins/acryl-inspect/tests/report.spec.ts +0 -69
- package/plugins/acryl-inspect/tests/service.spec.ts +0 -121
- package/plugins/acryl-node-server/tests/adapter/app.ts +0 -76
- package/plugins/acryl-node-server/tests/adapter/assets/.static/plain.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/favicon.ico +0 -0
- package/plugins/acryl-node-server/tests/adapter/assets/secret.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/acryl.html +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/admin/secret.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/data.json +0 -5
- package/plugins/acryl-node-server/tests/adapter/assets/static/extensionless +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/foo..bar.txt +0 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/index.html +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/plain.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-context-path/plain.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin.br +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.br +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.zst +0 -1
- package/plugins/acryl-node-server/tests/adapter/conninfo.test.ts +0 -34
- package/plugins/acryl-node-server/tests/adapter/content-length.test.ts +0 -248
- package/plugins/acryl-node-server/tests/adapter/early-hints.test.ts +0 -457
- package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-cert.pem +0 -23
- package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-key.pem +0 -27
- package/plugins/acryl-node-server/tests/adapter/headers.test.ts +0 -252
- package/plugins/acryl-node-server/tests/adapter/helpers/request.ts +0 -190
- package/plugins/acryl-node-server/tests/adapter/listener.test.ts +0 -727
- package/plugins/acryl-node-server/tests/adapter/request-client-disconnect.test.ts +0 -189
- package/plugins/acryl-node-server/tests/adapter/request.test.ts +0 -1230
- package/plugins/acryl-node-server/tests/adapter/response.test.ts +0 -285
- package/plugins/acryl-node-server/tests/adapter/serve-static.test.ts +0 -849
- package/plugins/acryl-node-server/tests/adapter/server-socket.test.ts +0 -790
- package/plugins/acryl-node-server/tests/adapter/server.test.ts +0 -1312
- package/plugins/acryl-node-server/tests/adapter/setup.ts +0 -16
- package/plugins/acryl-node-server/tests/adapter/url.test.ts +0 -76
- package/plugins/acryl-node-server/tests/adapter/utils/response.test.ts +0 -23
- package/plugins/acryl-node-server/tests/adapter/utils/stream.test.ts +0 -75
- package/plugins/acryl-node-server/tests/adapter/utils.test.ts +0 -235
- package/plugins/acryl-node-server/tests/adapter/websocket.test.ts +0 -260
- package/plugins/acryl-node-server/tests/server.spec.ts +0 -141
- package/plugins/acryl-router/src/core/app.test.ts +0 -3833
- package/plugins/acryl-router/src/core/client/client.test.ts +0 -2313
- package/plugins/acryl-router/src/core/client/types.test.ts +0 -149
- package/plugins/acryl-router/src/core/client/utils.test.ts +0 -405
- package/plugins/acryl-router/src/core/compose.test.ts +0 -751
- package/plugins/acryl-router/src/core/context.test.ts +0 -629
- package/plugins/acryl-router/src/core/helper/accepts/accepts.test.ts +0 -344
- package/plugins/acryl-router/src/core/helper/adapter/index.test.ts +0 -55
- package/plugins/acryl-router/src/core/helper/cookie/index.test.ts +0 -510
- package/plugins/acryl-router/src/core/helper/css/common.case.test.tsx +0 -506
- package/plugins/acryl-router/src/core/helper/css/index.test.tsx +0 -678
- package/plugins/acryl-router/src/core/helper/dev/index.test.ts +0 -181
- package/plugins/acryl-router/src/core/helper/factory/index.test.ts +0 -434
- package/plugins/acryl-router/src/core/helper/html/index.test.ts +0 -78
- package/plugins/acryl-router/src/core/helper/proxy/index.test.ts +0 -356
- package/plugins/acryl-router/src/core/helper/route/index.test.ts +0 -259
- package/plugins/acryl-router/src/core/helper/streaming/sse.test.tsx +0 -557
- package/plugins/acryl-router/src/core/helper/streaming/stream.test.ts +0 -128
- package/plugins/acryl-router/src/core/helper/streaming/text.test.ts +0 -34
- package/plugins/acryl-router/src/core/helper/testing/index.test.ts +0 -42
- package/plugins/acryl-router/src/core/helper/websocket/index.test.ts +0 -124
- package/plugins/acryl-router/src/core/http-exception.test.ts +0 -45
- package/plugins/acryl-router/src/core/jsx/base.test.tsx +0 -97
- package/plugins/acryl-router/src/core/jsx/children.test.ts +0 -52
- package/plugins/acryl-router/src/core/jsx/components.test.tsx +0 -936
- package/plugins/acryl-router/src/core/jsx/context-isolation.test.ts +0 -655
- package/plugins/acryl-router/src/core/jsx/dom/client.test.tsx +0 -128
- package/plugins/acryl-router/src/core/jsx/dom/components.test.tsx +0 -330
- package/plugins/acryl-router/src/core/jsx/dom/context.test.tsx +0 -184
- package/plugins/acryl-router/src/core/jsx/dom/css.test.tsx +0 -149
- package/plugins/acryl-router/src/core/jsx/dom/hooks/index.test.tsx +0 -172
- package/plugins/acryl-router/src/core/jsx/dom/index.test.tsx +0 -3681
- package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.test.tsx +0 -1344
- package/plugins/acryl-router/src/core/jsx/dom/server.test.tsx +0 -199
- package/plugins/acryl-router/src/core/jsx/hooks/dom.test.tsx +0 -859
- package/plugins/acryl-router/src/core/jsx/hooks/string.test.tsx +0 -40
- package/plugins/acryl-router/src/core/jsx/index.test.tsx +0 -1744
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.test.tsx +0 -666
- package/plugins/acryl-router/src/core/jsx/jsx-runtime.test.tsx +0 -85
- package/plugins/acryl-router/src/core/jsx/streaming.test.tsx +0 -1281
- package/plugins/acryl-router/src/core/jsx/utils.test.ts +0 -366
- package/plugins/acryl-router/src/core/middleware/basic-auth/index.test.ts +0 -434
- package/plugins/acryl-router/src/core/middleware/bearer-auth/index.test.ts +0 -1018
- package/plugins/acryl-router/src/core/middleware/body-limit/index.test.ts +0 -273
- package/plugins/acryl-router/src/core/middleware/cache/index.test.ts +0 -1211
- package/plugins/acryl-router/src/core/middleware/combine/index.test.ts +0 -355
- package/plugins/acryl-router/src/core/middleware/compress/index.test.ts +0 -535
- package/plugins/acryl-router/src/core/middleware/context-storage/index.test.ts +0 -43
- package/plugins/acryl-router/src/core/middleware/cors/index.test.ts +0 -532
- package/plugins/acryl-router/src/core/middleware/csrf/index.test.ts +0 -534
- package/plugins/acryl-router/src/core/middleware/etag/digest.test.ts +0 -21
- package/plugins/acryl-router/src/core/middleware/etag/index.test.ts +0 -503
- package/plugins/acryl-router/src/core/middleware/ip-restriction/index.test.ts +0 -217
- package/plugins/acryl-router/src/core/middleware/jwk/index.test.ts +0 -1135
- package/plugins/acryl-router/src/core/middleware/jwk/keys.test.json +0 -48
- package/plugins/acryl-router/src/core/middleware/jwt/index.test.ts +0 -802
- package/plugins/acryl-router/src/core/middleware/language/index.test.ts +0 -552
- package/plugins/acryl-router/src/core/middleware/logger/index.test.ts +0 -204
- package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.test.ts +0 -292
- package/plugins/acryl-router/src/core/middleware/method-override/index.test.ts +0 -221
- package/plugins/acryl-router/src/core/middleware/mount/index.test.ts +0 -334
- package/plugins/acryl-router/src/core/middleware/powered-by/index.test.ts +0 -37
- package/plugins/acryl-router/src/core/middleware/pretty-json/index.test.ts +0 -218
- package/plugins/acryl-router/src/core/middleware/request-id/index.test.ts +0 -168
- package/plugins/acryl-router/src/core/middleware/secure-headers/index.test.ts +0 -671
- package/plugins/acryl-router/src/core/middleware/serve-static/index.test.ts +0 -450
- package/plugins/acryl-router/src/core/middleware/serve-static/path.test.ts +0 -50
- package/plugins/acryl-router/src/core/middleware/timeout/index.test.ts +0 -70
- package/plugins/acryl-router/src/core/middleware/timing/index.test.ts +0 -310
- package/plugins/acryl-router/src/core/middleware/trailing-slash/index.test.ts +0 -381
- package/plugins/acryl-router/src/core/preset/quick.test.ts +0 -42
- package/plugins/acryl-router/src/core/preset/tiny.test.ts +0 -42
- package/plugins/acryl-router/src/core/request.test.ts +0 -751
- package/plugins/acryl-router/src/core/router/common.case.test.ts +0 -1132
- package/plugins/acryl-router/src/core/router/linear-router/router.test.ts +0 -80
- package/plugins/acryl-router/src/core/router/pattern-router/router.test.ts +0 -46
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.test.ts +0 -154
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.test.ts +0 -265
- package/plugins/acryl-router/src/core/router/smart-router/router.test.ts +0 -13
- package/plugins/acryl-router/src/core/router/trie-router/node.test.ts +0 -896
- package/plugins/acryl-router/src/core/router/trie-router/router.test.ts +0 -8
- package/plugins/acryl-router/src/core/types.test.ts +0 -4134
- package/plugins/acryl-router/src/core/utils/accept.test.ts +0 -299
- package/plugins/acryl-router/src/core/utils/basic-auth.test.ts +0 -56
- package/plugins/acryl-router/src/core/utils/body.test.ts +0 -496
- package/plugins/acryl-router/src/core/utils/buffer.test.ts +0 -147
- package/plugins/acryl-router/src/core/utils/color.test.ts +0 -23
- package/plugins/acryl-router/src/core/utils/concurrent.test.ts +0 -69
- package/plugins/acryl-router/src/core/utils/cookie.test.ts +0 -460
- package/plugins/acryl-router/src/core/utils/crypto.test.ts +0 -43
- package/plugins/acryl-router/src/core/utils/encode.test.ts +0 -61
- package/plugins/acryl-router/src/core/utils/filepath.test.ts +0 -78
- package/plugins/acryl-router/src/core/utils/html.test.ts +0 -16
- package/plugins/acryl-router/src/core/utils/ipaddr.test.ts +0 -149
- package/plugins/acryl-router/src/core/utils/jwt/jwa.test.ts +0 -86
- package/plugins/acryl-router/src/core/utils/jwt/jwt.test.ts +0 -1788
- package/plugins/acryl-router/src/core/utils/mime.test.ts +0 -64
- package/plugins/acryl-router/src/core/utils/stream.test.ts +0 -212
- package/plugins/acryl-router/src/core/utils/types.test.ts +0 -295
- package/plugins/acryl-router/src/core/utils/url.test.ts +0 -384
- package/plugins/acryl-router/src/core/validator/utils.test.ts +0 -82
- package/plugins/acryl-router/src/core/validator/validator.test.ts +0 -1488
- package/plugins/acryl-router/tests/docs-examples.spec.ts +0 -152
- package/plugins/acryl-router/tests/jsx.spec.tsx +0 -63
- package/plugins/acryl-router/tests/live-install.spec.ts +0 -64
- package/plugins/acryl-router/tests/loader.spec.ts +0 -72
- package/plugins/acryl-router/tests/loopback-only.spec.ts +0 -80
- package/plugins/acryl-router/tests/no-dom/consumer.ts +0 -11
- package/plugins/acryl-router/tests/no-dom/tsconfig.json +0 -13
- package/plugins/acryl-router/tests/service.spec.ts +0 -426
- package/plugins/acryl-router/tests/shadow-state.spec.ts +0 -79
- package/plugins/acryl-router-http/tests/adapter.spec.ts +0 -174
- package/plugins/acryl-router-http/tests/stream.spec.ts +0 -133
- package/plugins/acryl-router-http/tests/surfaces.spec.ts +0 -101
- package/plugins/acryl-state/src/react.ts +0 -11
- package/plugins/acryl-state/tests/cell.spec.ts +0 -71
- package/plugins/acryl-state/tests/react.spec.ts +0 -39
- package/plugins/acryl-state/tests/service.spec.ts +0 -132
|
@@ -1,666 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource ../ */
|
|
2
|
-
import { useActionState } from '../index.ts'
|
|
3
|
-
import { HtmlEscapedCallbackPhase, resolveCallback } from '../../utils/html.ts'
|
|
4
|
-
|
|
5
|
-
describe('intrinsic element', () => {
|
|
6
|
-
describe('document metadata', () => {
|
|
7
|
-
describe('title element', () => {
|
|
8
|
-
it('should be hoisted title tag', async () => {
|
|
9
|
-
const template = (
|
|
10
|
-
<html>
|
|
11
|
-
<head></head>
|
|
12
|
-
<body>
|
|
13
|
-
<title>Hello</title>
|
|
14
|
-
<h1>World</h1>
|
|
15
|
-
</body>
|
|
16
|
-
</html>
|
|
17
|
-
)
|
|
18
|
-
expect(template.toString()).toBe(
|
|
19
|
-
'<html><head><title>Hello</title></head><body><h1>World</h1></body></html>'
|
|
20
|
-
)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('should hoist a title from an async component array', async () => {
|
|
24
|
-
const Metadata = async () => [<title>Hello</title>]
|
|
25
|
-
const template = (
|
|
26
|
-
<html>
|
|
27
|
-
<head></head>
|
|
28
|
-
<body>
|
|
29
|
-
<Metadata />
|
|
30
|
-
<h1>World</h1>
|
|
31
|
-
</body>
|
|
32
|
-
</html>
|
|
33
|
-
)
|
|
34
|
-
const rendered = await template.toString()
|
|
35
|
-
expect(await resolveCallback(rendered, HtmlEscapedCallbackPhase.Stringify, false, {})).toBe(
|
|
36
|
-
'<html><head><title>Hello</title></head><body><h1>World</h1></body></html>'
|
|
37
|
-
)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('should hoist a title with async children', async () => {
|
|
41
|
-
const AsyncChild = async () => <>{'Hello'}</>
|
|
42
|
-
const template = (
|
|
43
|
-
<html>
|
|
44
|
-
<head></head>
|
|
45
|
-
<body>
|
|
46
|
-
<title>
|
|
47
|
-
<AsyncChild />
|
|
48
|
-
</title>
|
|
49
|
-
<h1>World</h1>
|
|
50
|
-
</body>
|
|
51
|
-
</html>
|
|
52
|
-
)
|
|
53
|
-
const rendered = await template.toString()
|
|
54
|
-
expect(await resolveCallback(rendered, HtmlEscapedCallbackPhase.Stringify, false, {})).toBe(
|
|
55
|
-
'<html><head><title>Hello</title></head><body><h1>World</h1></body></html>'
|
|
56
|
-
)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should render a title with async children without a head element', async () => {
|
|
60
|
-
const AsyncChild = async () => <>{'Hello'}</>
|
|
61
|
-
const template = (
|
|
62
|
-
<html>
|
|
63
|
-
<body>
|
|
64
|
-
<title>
|
|
65
|
-
<AsyncChild />
|
|
66
|
-
</title>
|
|
67
|
-
<h1>World</h1>
|
|
68
|
-
</body>
|
|
69
|
-
</html>
|
|
70
|
-
)
|
|
71
|
-
const rendered = await template.toString()
|
|
72
|
-
const html = await resolveCallback(rendered, HtmlEscapedCallbackPhase.Stringify, false, {})
|
|
73
|
-
expect(html.toString()).toBe('<html><body><title>Hello</title><h1>World</h1></body></html>')
|
|
74
|
-
expect(html.toString()).not.toContain('[object Promise]')
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
it('should render a title with itemProp and async children', async () => {
|
|
78
|
-
const AsyncChild = async () => <>{'price < 100'}</>
|
|
79
|
-
const template = <title itemProp='name'>{<AsyncChild />}</title>
|
|
80
|
-
|
|
81
|
-
expect(String(await template.toString())).toBe(
|
|
82
|
-
'<title itemprop="name">price < 100</title>'
|
|
83
|
-
)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('should not interpret replacement patterns in a hoisted title', async () => {
|
|
87
|
-
const template = (
|
|
88
|
-
<html>
|
|
89
|
-
<head></head>
|
|
90
|
-
<body>
|
|
91
|
-
<title>{'price $< 100'}</title>
|
|
92
|
-
</body>
|
|
93
|
-
</html>
|
|
94
|
-
)
|
|
95
|
-
const rendered = await template.toString()
|
|
96
|
-
|
|
97
|
-
expect(await resolveCallback(rendered, HtmlEscapedCallbackPhase.Stringify, false, {})).toBe(
|
|
98
|
-
'<html><head><title>price $< 100</title></head><body></body></html>'
|
|
99
|
-
)
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
describe('link element', () => {
|
|
104
|
-
it('should be hoisted link tag', async () => {
|
|
105
|
-
const template = (
|
|
106
|
-
<html>
|
|
107
|
-
<head></head>
|
|
108
|
-
<body>
|
|
109
|
-
<link rel='stylesheet' href='style.css' precedence='default' />
|
|
110
|
-
<h1>World</h1>
|
|
111
|
-
</body>
|
|
112
|
-
</html>
|
|
113
|
-
)
|
|
114
|
-
expect(template.toString()).toBe(
|
|
115
|
-
'<html><head><link rel="stylesheet" href="style.css" data-precedence="default"/></head><body><h1>World</h1></body></html>'
|
|
116
|
-
)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('should be ordered by precedence attribute', () => {
|
|
120
|
-
const template = (
|
|
121
|
-
<html>
|
|
122
|
-
<head></head>
|
|
123
|
-
<body>
|
|
124
|
-
<link rel='stylesheet' href='style1.css' precedence='default' />
|
|
125
|
-
<link rel='stylesheet' href='style2.css' precedence='high' />
|
|
126
|
-
<link rel='stylesheet' href='style3.css' precedence='default' />
|
|
127
|
-
<h1>World</h1>
|
|
128
|
-
</body>
|
|
129
|
-
</html>
|
|
130
|
-
)
|
|
131
|
-
expect(template.toString()).toBe(
|
|
132
|
-
'<html><head><link rel="stylesheet" href="style1.css" data-precedence="default"/><link rel="stylesheet" href="style3.css" data-precedence="default"/><link rel="stylesheet" href="style2.css" data-precedence="high"/></head><body><h1>World</h1></body></html>'
|
|
133
|
-
)
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
it('should be de-duped by href', () => {
|
|
137
|
-
const template = (
|
|
138
|
-
<html>
|
|
139
|
-
<head></head>
|
|
140
|
-
<body>
|
|
141
|
-
<link rel='stylesheet' href='style1.css' precedence='default' />
|
|
142
|
-
<link rel='stylesheet' href='style2.css' precedence='high' />
|
|
143
|
-
<link rel='stylesheet' href='style1.css' precedence='default' />
|
|
144
|
-
<h1>World</h1>
|
|
145
|
-
</body>
|
|
146
|
-
</html>
|
|
147
|
-
)
|
|
148
|
-
expect(template.toString()).toBe(
|
|
149
|
-
'<html><head><link rel="stylesheet" href="style1.css" data-precedence="default"/><link rel="stylesheet" href="style2.css" data-precedence="high"/></head><body><h1>World</h1></body></html>'
|
|
150
|
-
)
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
it('should be inserted as is if <head> is not present', () => {
|
|
154
|
-
const template = (
|
|
155
|
-
<html>
|
|
156
|
-
<body>
|
|
157
|
-
<link rel='stylesheet' href='style1.css' precedence='default' />
|
|
158
|
-
<link rel='stylesheet' href='style2.css' precedence='high' />
|
|
159
|
-
<h1>World</h1>
|
|
160
|
-
</body>
|
|
161
|
-
</html>
|
|
162
|
-
)
|
|
163
|
-
expect(template.toString()).toBe(
|
|
164
|
-
'<html><body><link rel="stylesheet" href="style1.css" data-precedence="default"/><link rel="stylesheet" href="style2.css" data-precedence="high"/><h1>World</h1></body></html>'
|
|
165
|
-
)
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('should not do special behavior if disabled is present', () => {
|
|
169
|
-
const template = (
|
|
170
|
-
<html>
|
|
171
|
-
<head></head>
|
|
172
|
-
<body>
|
|
173
|
-
<link rel='stylesheet' href='style1.css' precedence='default' />
|
|
174
|
-
<link rel='stylesheet' href='style2.css' precedence='default' disabled />
|
|
175
|
-
<h1>World</h1>
|
|
176
|
-
</body>
|
|
177
|
-
</html>
|
|
178
|
-
)
|
|
179
|
-
expect(template.toString()).toBe(
|
|
180
|
-
'<html><head><link rel="stylesheet" href="style1.css" data-precedence="default"/></head><body><link rel="stylesheet" href="style2.css" precedence="default" disabled=""/><h1>World</h1></body></html>'
|
|
181
|
-
)
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
it('should not be hoisted if has no precedence attribute', () => {
|
|
185
|
-
const template = (
|
|
186
|
-
<html>
|
|
187
|
-
<head></head>
|
|
188
|
-
<body>
|
|
189
|
-
<link rel='stylesheet' href='style1.css' />
|
|
190
|
-
<h1>World</h1>
|
|
191
|
-
</body>
|
|
192
|
-
</html>
|
|
193
|
-
)
|
|
194
|
-
expect(template.toString()).toBe(
|
|
195
|
-
'<html><head></head><body><link rel="stylesheet" href="style1.css"/><h1>World</h1></body></html>'
|
|
196
|
-
)
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
describe('React 19 compatibility', () => {
|
|
200
|
-
const headContent = (html: string) => html.match(/<head>(.*)<\/head>/)?.[1] ?? ''
|
|
201
|
-
const bodyContent = (html: string) => html.match(/<body>(.*)<\/body>/)?.[1] ?? ''
|
|
202
|
-
const renderDocument = (children: unknown) =>
|
|
203
|
-
(
|
|
204
|
-
<html>
|
|
205
|
-
<head></head>
|
|
206
|
-
<body>{children}</body>
|
|
207
|
-
</html>
|
|
208
|
-
).toString()
|
|
209
|
-
const assertHeadAndBody = (children: unknown, expectedHead: string, expectedBody = '') => {
|
|
210
|
-
const output = renderDocument(children)
|
|
211
|
-
expect(headContent(output)).toBe(expectedHead)
|
|
212
|
-
expect(bodyContent(output)).toBe(expectedBody)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const canonical = () => <link rel='canonical' href='https://example.com/en/about' />
|
|
216
|
-
const alternateEn = () => (
|
|
217
|
-
<link rel='alternate' hrefLang='en' href='https://example.com/en/about' />
|
|
218
|
-
)
|
|
219
|
-
const alternateJa = () => (
|
|
220
|
-
<link rel='alternate' hrefLang='ja' href='https://example.com/ja/about' />
|
|
221
|
-
)
|
|
222
|
-
|
|
223
|
-
it('should keep canonical and alternates in source order', () => {
|
|
224
|
-
assertHeadAndBody(
|
|
225
|
-
<>
|
|
226
|
-
{canonical()}
|
|
227
|
-
{alternateEn()}
|
|
228
|
-
{alternateJa()}
|
|
229
|
-
</>,
|
|
230
|
-
'<link rel="canonical" href="https://example.com/en/about"/><link rel="alternate" hrefLang="en" href="https://example.com/en/about"/><link rel="alternate" hrefLang="ja" href="https://example.com/ja/about"/>'
|
|
231
|
-
)
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
it('should keep alternate-canonical-alternate order', () => {
|
|
235
|
-
assertHeadAndBody(
|
|
236
|
-
<>
|
|
237
|
-
{alternateEn()}
|
|
238
|
-
{canonical()}
|
|
239
|
-
{alternateJa()}
|
|
240
|
-
</>,
|
|
241
|
-
'<link rel="alternate" hrefLang="en" href="https://example.com/en/about"/><link rel="canonical" href="https://example.com/en/about"/><link rel="alternate" hrefLang="ja" href="https://example.com/ja/about"/>'
|
|
242
|
-
)
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
it('should not de-dupe canonical links', () => {
|
|
246
|
-
assertHeadAndBody(
|
|
247
|
-
<>
|
|
248
|
-
{canonical()}
|
|
249
|
-
{canonical()}
|
|
250
|
-
</>,
|
|
251
|
-
'<link rel="canonical" href="https://example.com/en/about"/><link rel="canonical" href="https://example.com/en/about"/>'
|
|
252
|
-
)
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
it('should not de-dupe alternate links', () => {
|
|
256
|
-
assertHeadAndBody(
|
|
257
|
-
<>
|
|
258
|
-
{alternateEn()}
|
|
259
|
-
{alternateEn()}
|
|
260
|
-
</>,
|
|
261
|
-
'<link rel="alternate" hrefLang="en" href="https://example.com/en/about"/><link rel="alternate" hrefLang="en" href="https://example.com/en/about"/>'
|
|
262
|
-
)
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
it('should de-dupe stylesheet with precedence', () => {
|
|
266
|
-
assertHeadAndBody(
|
|
267
|
-
<>
|
|
268
|
-
<link rel='stylesheet' href='/style.css' precedence='default' />
|
|
269
|
-
<link rel='stylesheet' href='/style.css' precedence='default' />
|
|
270
|
-
</>,
|
|
271
|
-
'<link rel="stylesheet" href="/style.css" data-precedence="default"/>'
|
|
272
|
-
)
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
it('should not de-dupe stylesheet against preload with same href', () => {
|
|
276
|
-
assertHeadAndBody(
|
|
277
|
-
<>
|
|
278
|
-
<link rel='preload' href='/style.css' as='style' />
|
|
279
|
-
<link rel='stylesheet' href='/style.css' precedence='default' />
|
|
280
|
-
<link rel='stylesheet' href='/style.css' precedence='default' />
|
|
281
|
-
</>,
|
|
282
|
-
'<link rel="stylesheet" href="/style.css" data-precedence="default"/><link rel="preload" href="/style.css" as="style"/>'
|
|
283
|
-
)
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
it('should not hoist stylesheet without precedence', () => {
|
|
287
|
-
assertHeadAndBody(
|
|
288
|
-
<>
|
|
289
|
-
<link rel='stylesheet' href='/style.css' />
|
|
290
|
-
<link rel='stylesheet' href='/style.css' />
|
|
291
|
-
</>,
|
|
292
|
-
'',
|
|
293
|
-
'<link rel="stylesheet" href="/style.css"/><link rel="stylesheet" href="/style.css"/>'
|
|
294
|
-
)
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
it('should keep different stylesheets with same precedence', () => {
|
|
298
|
-
assertHeadAndBody(
|
|
299
|
-
<>
|
|
300
|
-
<link rel='stylesheet' href='/a.css' precedence='default' />
|
|
301
|
-
<link rel='stylesheet' href='/b.css' precedence='default' />
|
|
302
|
-
</>,
|
|
303
|
-
'<link rel="stylesheet" href="/a.css" data-precedence="default"/><link rel="stylesheet" href="/b.css" data-precedence="default"/>'
|
|
304
|
-
)
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
it('should not de-dupe preload links', () => {
|
|
308
|
-
assertHeadAndBody(
|
|
309
|
-
<>
|
|
310
|
-
<link rel='preload' href='/font.woff2' as='font' crossOrigin='' />
|
|
311
|
-
<link rel='preload' href='/font.woff2' as='font' crossOrigin='' />
|
|
312
|
-
</>,
|
|
313
|
-
'<link rel="preload" href="/font.woff2" as="font" crossorigin=""/><link rel="preload" href="/font.woff2" as="font" crossorigin=""/>'
|
|
314
|
-
)
|
|
315
|
-
})
|
|
316
|
-
|
|
317
|
-
it('should not de-dupe modulepreload links', () => {
|
|
318
|
-
assertHeadAndBody(
|
|
319
|
-
<>
|
|
320
|
-
<link rel='modulepreload' href='/module.js' />
|
|
321
|
-
<link rel='modulepreload' href='/module.js' />
|
|
322
|
-
</>,
|
|
323
|
-
'<link rel="modulepreload" href="/module.js"/><link rel="modulepreload" href="/module.js"/>'
|
|
324
|
-
)
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
it('should keep links from two components', () => {
|
|
328
|
-
const Head = () => (
|
|
329
|
-
<>
|
|
330
|
-
<link rel='canonical' href='https://example.com/en/about' />
|
|
331
|
-
<link rel='alternate' hrefLang='en' href='https://example.com/en/about' />
|
|
332
|
-
<link rel='alternate' hrefLang='ja' href='https://example.com/ja/about' />
|
|
333
|
-
</>
|
|
334
|
-
)
|
|
335
|
-
const Body = () => (
|
|
336
|
-
<>
|
|
337
|
-
<link rel='canonical' href='https://example.com/en/about' />
|
|
338
|
-
<link rel='alternate' hrefLang='en' href='https://example.com/en/about' />
|
|
339
|
-
<link rel='alternate' hrefLang='ja' href='https://example.com/ja/about' />
|
|
340
|
-
</>
|
|
341
|
-
)
|
|
342
|
-
assertHeadAndBody(
|
|
343
|
-
<>
|
|
344
|
-
<Head />
|
|
345
|
-
<Body />
|
|
346
|
-
</>,
|
|
347
|
-
'<link rel="canonical" href="https://example.com/en/about"/><link rel="alternate" hrefLang="en" href="https://example.com/en/about"/><link rel="alternate" hrefLang="ja" href="https://example.com/ja/about"/><link rel="canonical" href="https://example.com/en/about"/><link rel="alternate" hrefLang="en" href="https://example.com/en/about"/><link rel="alternate" hrefLang="ja" href="https://example.com/ja/about"/>'
|
|
348
|
-
)
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
it('should hoist from deep nested component and keep duplicates', () => {
|
|
352
|
-
const Nested = () => (
|
|
353
|
-
<div>
|
|
354
|
-
<div>
|
|
355
|
-
<link rel='canonical' href='https://example.com/en/about' />
|
|
356
|
-
</div>
|
|
357
|
-
</div>
|
|
358
|
-
)
|
|
359
|
-
assertHeadAndBody(
|
|
360
|
-
<>
|
|
361
|
-
<link rel='canonical' href='https://example.com/en/about' />
|
|
362
|
-
<Nested />
|
|
363
|
-
</>,
|
|
364
|
-
'<link rel="canonical" href="https://example.com/en/about"/><link rel="canonical" href="https://example.com/en/about"/>',
|
|
365
|
-
'<div><div></div></div>'
|
|
366
|
-
)
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
it('should keep mixed links and de-dupe only stylesheet', () => {
|
|
370
|
-
assertHeadAndBody(
|
|
371
|
-
<>
|
|
372
|
-
<link rel='canonical' href='https://example.com/en/about' />
|
|
373
|
-
<link rel='alternate' hrefLang='en' href='https://example.com/en/about' />
|
|
374
|
-
<link rel='stylesheet' href='/style.css' precedence='default' />
|
|
375
|
-
<link rel='preload' href='/font.woff2' as='font' crossOrigin='' />
|
|
376
|
-
<link rel='canonical' href='https://example.com/en/about' />
|
|
377
|
-
<link rel='alternate' hrefLang='en' href='https://example.com/en/about' />
|
|
378
|
-
<link rel='stylesheet' href='/style.css' precedence='default' />
|
|
379
|
-
<link rel='preload' href='/font.woff2' as='font' crossOrigin='' />
|
|
380
|
-
</>,
|
|
381
|
-
'<link rel="stylesheet" href="/style.css" data-precedence="default"/><link rel="canonical" href="https://example.com/en/about"/><link rel="alternate" hrefLang="en" href="https://example.com/en/about"/><link rel="preload" href="/font.woff2" as="font" crossorigin=""/><link rel="canonical" href="https://example.com/en/about"/><link rel="alternate" hrefLang="en" href="https://example.com/en/about"/><link rel="preload" href="/font.woff2" as="font" crossorigin=""/>'
|
|
382
|
-
)
|
|
383
|
-
})
|
|
384
|
-
})
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
describe('meta element', () => {
|
|
388
|
-
it('should be hoisted meta tag', async () => {
|
|
389
|
-
const template = (
|
|
390
|
-
<html>
|
|
391
|
-
<head></head>
|
|
392
|
-
<body>
|
|
393
|
-
<meta name='description' content='Hello' />
|
|
394
|
-
<h1>World</h1>
|
|
395
|
-
</body>
|
|
396
|
-
</html>
|
|
397
|
-
)
|
|
398
|
-
expect(template.toString()).toBe(
|
|
399
|
-
'<html><head><meta name="description" content="Hello"/></head><body><h1>World</h1></body></html>'
|
|
400
|
-
)
|
|
401
|
-
})
|
|
402
|
-
|
|
403
|
-
it('should be de-duped by name', () => {
|
|
404
|
-
const template = (
|
|
405
|
-
<html>
|
|
406
|
-
<head></head>
|
|
407
|
-
<body>
|
|
408
|
-
<meta name='description' content='Hello' />
|
|
409
|
-
<meta name='description' content='World' />
|
|
410
|
-
<h1>World</h1>
|
|
411
|
-
</body>
|
|
412
|
-
</html>
|
|
413
|
-
)
|
|
414
|
-
expect(template.toString()).toBe(
|
|
415
|
-
'<html><head><meta name="description" content="Hello"/></head><body><h1>World</h1></body></html>'
|
|
416
|
-
)
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
it('should not do special behavior if itemProp is present', () => {
|
|
420
|
-
const template = (
|
|
421
|
-
<html>
|
|
422
|
-
<head></head>
|
|
423
|
-
<body>
|
|
424
|
-
<meta name='description' content='Hello' itemProp='test' />
|
|
425
|
-
<h1>World</h1>
|
|
426
|
-
</body>
|
|
427
|
-
</html>
|
|
428
|
-
)
|
|
429
|
-
expect(template.toString()).toBe(
|
|
430
|
-
'<html><head></head><body><meta name="description" content="Hello" itemprop="test"/><h1>World</h1></body></html>'
|
|
431
|
-
)
|
|
432
|
-
})
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
describe('script element', () => {
|
|
436
|
-
it('should be hoisted script tag', async () => {
|
|
437
|
-
const template = (
|
|
438
|
-
<html>
|
|
439
|
-
<head></head>
|
|
440
|
-
<body>
|
|
441
|
-
<script src='script.js' async={true} />
|
|
442
|
-
<h1>World</h1>
|
|
443
|
-
</body>
|
|
444
|
-
</html>
|
|
445
|
-
)
|
|
446
|
-
expect(template.toString()).toBe(
|
|
447
|
-
'<html><head><script src="script.js" async=""></script></head><body><h1>World</h1></body></html>'
|
|
448
|
-
)
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
it('should be de-duped by href with async={true}', () => {
|
|
452
|
-
const template = (
|
|
453
|
-
<html>
|
|
454
|
-
<head></head>
|
|
455
|
-
<body>
|
|
456
|
-
<script src='script.js' async />
|
|
457
|
-
<script src='script.js' async />
|
|
458
|
-
<h1>World</h1>
|
|
459
|
-
</body>
|
|
460
|
-
</html>
|
|
461
|
-
)
|
|
462
|
-
expect(template.toString()).toBe(
|
|
463
|
-
'<html><head><script src="script.js" async=""></script></head><body><h1>World</h1></body></html>'
|
|
464
|
-
)
|
|
465
|
-
})
|
|
466
|
-
|
|
467
|
-
it('should be omitted "blocking", "onLoad" and "onError" props', () => {
|
|
468
|
-
const template = (
|
|
469
|
-
<html>
|
|
470
|
-
<head></head>
|
|
471
|
-
<body>
|
|
472
|
-
<script
|
|
473
|
-
src='script.js'
|
|
474
|
-
async={true}
|
|
475
|
-
onLoad={() => {}}
|
|
476
|
-
onError={() => {}}
|
|
477
|
-
blocking='render'
|
|
478
|
-
/>
|
|
479
|
-
<h1>World</h1>
|
|
480
|
-
</body>
|
|
481
|
-
</html>
|
|
482
|
-
)
|
|
483
|
-
expect(template.toString()).toBe(
|
|
484
|
-
'<html><head><script src="script.js" async=""></script></head><body><h1>World</h1></body></html>'
|
|
485
|
-
)
|
|
486
|
-
})
|
|
487
|
-
|
|
488
|
-
it('should not do special behavior if async is not present', () => {
|
|
489
|
-
const template = (
|
|
490
|
-
<html>
|
|
491
|
-
<head></head>
|
|
492
|
-
<body>
|
|
493
|
-
<script src='script.js' />
|
|
494
|
-
<h1>World</h1>
|
|
495
|
-
</body>
|
|
496
|
-
</html>
|
|
497
|
-
)
|
|
498
|
-
expect(template.toString()).toBe(
|
|
499
|
-
'<html><head></head><body><script src="script.js"></script><h1>World</h1></body></html>'
|
|
500
|
-
)
|
|
501
|
-
})
|
|
502
|
-
})
|
|
503
|
-
|
|
504
|
-
describe('style element', () => {
|
|
505
|
-
it('should be hoisted style tag', async () => {
|
|
506
|
-
const template = (
|
|
507
|
-
<html>
|
|
508
|
-
<head></head>
|
|
509
|
-
<body>
|
|
510
|
-
<style href='red' precedence='default'>
|
|
511
|
-
{'body { color: red; }'}
|
|
512
|
-
</style>
|
|
513
|
-
<h1>World</h1>
|
|
514
|
-
</body>
|
|
515
|
-
</html>
|
|
516
|
-
)
|
|
517
|
-
expect(template.toString()).toBe(
|
|
518
|
-
'<html><head><style data-href="red" data-precedence="default">body { color: red; }</style></head><body><h1>World</h1></body></html>'
|
|
519
|
-
)
|
|
520
|
-
})
|
|
521
|
-
|
|
522
|
-
it('should be sorted by precedence attribute', async () => {
|
|
523
|
-
const template = (
|
|
524
|
-
<html>
|
|
525
|
-
<head></head>
|
|
526
|
-
<body>
|
|
527
|
-
<style href='red' precedence='default'>
|
|
528
|
-
{'body { color: red; }'}
|
|
529
|
-
</style>
|
|
530
|
-
<style href='green' precedence='high'>
|
|
531
|
-
{'body { color: green; }'}
|
|
532
|
-
</style>
|
|
533
|
-
<style href='blue' precedence='default'>
|
|
534
|
-
{'body { color: blue; }'}
|
|
535
|
-
</style>
|
|
536
|
-
<h1>World</h1>
|
|
537
|
-
</body>
|
|
538
|
-
</html>
|
|
539
|
-
)
|
|
540
|
-
expect(template.toString()).toBe(
|
|
541
|
-
'<html><head><style data-href="red" data-precedence="default">body { color: red; }</style><style data-href="blue" data-precedence="default">body { color: blue; }</style><style data-href="green" data-precedence="high">body { color: green; }</style></head><body><h1>World</h1></body></html>'
|
|
542
|
-
)
|
|
543
|
-
})
|
|
544
|
-
|
|
545
|
-
it('should not be hoisted if href is not present', () => {
|
|
546
|
-
const template = (
|
|
547
|
-
<html>
|
|
548
|
-
<head></head>
|
|
549
|
-
<body>
|
|
550
|
-
<style>{'body { color: red; }'}</style>
|
|
551
|
-
<h1>World</h1>
|
|
552
|
-
</body>
|
|
553
|
-
</html>
|
|
554
|
-
)
|
|
555
|
-
expect(template.toString()).toBe(
|
|
556
|
-
'<html><head></head><body><style>body { color: red; }</style><h1>World</h1></body></html>'
|
|
557
|
-
)
|
|
558
|
-
})
|
|
559
|
-
})
|
|
560
|
-
})
|
|
561
|
-
|
|
562
|
-
describe('form element', () => {
|
|
563
|
-
it('should be omitted "action" prop if it is a function', () => {
|
|
564
|
-
const template = (
|
|
565
|
-
<html>
|
|
566
|
-
<head></head>
|
|
567
|
-
<body>
|
|
568
|
-
<form action={() => {}} method='get'>
|
|
569
|
-
<input type='text' />
|
|
570
|
-
</form>
|
|
571
|
-
</body>
|
|
572
|
-
</html>
|
|
573
|
-
)
|
|
574
|
-
expect(template.toString()).toBe(
|
|
575
|
-
'<html><head></head><body><form method="get"><input type="text"/></form></body></html>'
|
|
576
|
-
)
|
|
577
|
-
})
|
|
578
|
-
|
|
579
|
-
it('should be rendered permalink', () => {
|
|
580
|
-
const [, action] = useActionState(() => {}, {}, 'permalink')
|
|
581
|
-
const template = (
|
|
582
|
-
<html>
|
|
583
|
-
<head></head>
|
|
584
|
-
<body>
|
|
585
|
-
<form action={action} method='get'>
|
|
586
|
-
<input type='text' />
|
|
587
|
-
</form>
|
|
588
|
-
</body>
|
|
589
|
-
</html>
|
|
590
|
-
)
|
|
591
|
-
expect(template.toString()).toBe(
|
|
592
|
-
'<html><head></head><body><form action="permalink" method="get"><input type="text"/></form></body></html>'
|
|
593
|
-
)
|
|
594
|
-
})
|
|
595
|
-
|
|
596
|
-
it('should not do special behavior if action is a string', () => {
|
|
597
|
-
const template = (
|
|
598
|
-
<html>
|
|
599
|
-
<head></head>
|
|
600
|
-
<body>
|
|
601
|
-
<form action='/entries' method='get'>
|
|
602
|
-
<input type='text' />
|
|
603
|
-
</form>
|
|
604
|
-
</body>
|
|
605
|
-
</html>
|
|
606
|
-
)
|
|
607
|
-
expect(template.toString()).toBe(
|
|
608
|
-
'<html><head></head><body><form action="/entries" method="get"><input type="text"/></form></body></html>'
|
|
609
|
-
)
|
|
610
|
-
})
|
|
611
|
-
|
|
612
|
-
it('should not do special behavior if no action prop', () => {
|
|
613
|
-
const template = (
|
|
614
|
-
<html>
|
|
615
|
-
<head></head>
|
|
616
|
-
<body>
|
|
617
|
-
<form>
|
|
618
|
-
<input type='text' />
|
|
619
|
-
</form>
|
|
620
|
-
</body>
|
|
621
|
-
</html>
|
|
622
|
-
)
|
|
623
|
-
expect(template.toString()).toBe(
|
|
624
|
-
'<html><head></head><body><form><input type="text"/></form></body></html>'
|
|
625
|
-
)
|
|
626
|
-
})
|
|
627
|
-
|
|
628
|
-
describe('input element', () => {
|
|
629
|
-
it('should be rendered as is', () => {
|
|
630
|
-
const template = <input type='text' />
|
|
631
|
-
expect(template.toString()).toBe('<input type="text"/>')
|
|
632
|
-
})
|
|
633
|
-
|
|
634
|
-
it('should be omitted "formAction" prop if it is a function', () => {
|
|
635
|
-
const template = (
|
|
636
|
-
<html>
|
|
637
|
-
<head></head>
|
|
638
|
-
<body>
|
|
639
|
-
<input type='text' formAction={() => {}} />
|
|
640
|
-
</body>
|
|
641
|
-
</html>
|
|
642
|
-
)
|
|
643
|
-
expect(template.toString()).toBe(
|
|
644
|
-
'<html><head></head><body><input type="text"/></body></html>'
|
|
645
|
-
)
|
|
646
|
-
})
|
|
647
|
-
|
|
648
|
-
it('should be rendered permalink', () => {
|
|
649
|
-
const [, formAction] = useActionState(() => {}, {}, 'permalink')
|
|
650
|
-
const template = (
|
|
651
|
-
<html>
|
|
652
|
-
<head></head>
|
|
653
|
-
<body>
|
|
654
|
-
<input type='text' formAction={formAction} />
|
|
655
|
-
</body>
|
|
656
|
-
</html>
|
|
657
|
-
)
|
|
658
|
-
expect(template.toString()).toBe(
|
|
659
|
-
'<html><head></head><body><input type="text" formaction="permalink"/></body></html>'
|
|
660
|
-
)
|
|
661
|
-
})
|
|
662
|
-
})
|
|
663
|
-
})
|
|
664
|
-
})
|
|
665
|
-
|
|
666
|
-
export {}
|