Skip to content

Commit

Permalink
Support __c contextRef (#493)
Browse files Browse the repository at this point in the history
* Support __c contextRef

* Incorporate `_id` change

* Fix booboo

* Try some stuff out

* Run dedupe

* 🤷

* Install
  • Loading branch information
JoviDeCroock authored Jan 7, 2025
1 parent a767168 commit 5f94f09
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 818 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install Deps
run: yarn
- name: Install Playwright
run: yarn playwright install-deps chromium
run: yarn playwright install --with-deps && yarn playwright install-deps chromium
- name: Run tests
run: |
yarn lint
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"build:firefox": "node tools/build.mjs --browser firefox",
"build:inline:types": "tsc -p tsconfig.inline.json",
"build:inline": "node tools/build.mjs --browser inline && tsc -p tsconfig.inline.json",
"archive": "git archive --form at zip --output dist/source-code.zip main",
"archive": "git archive --format zip --output dist/source-code.zip main",
"lint": "eslint 'src/**/*.{ts,tsx}' 'test-e2e/**/*.ts'",
"test": "mochette -c tsconfig.cjs.json -r tools/test-setup.js 'src/**/*.test.{ts,tsx}'",
"test:e2e": "node tools/fetch-preact-versions.mjs && playwright test",
Expand All @@ -49,7 +49,7 @@
"@babel/core": "^7.18.10",
"@babel/plugin-syntax-typescript": "^7.18.6",
"@babel/plugin-transform-react-jsx": "^7.18.10",
"@playwright/test": "^1.49.0",
"@playwright/test": "^1.49.1",
"@preact/preset-vite": "^2.8.2",
"@preact/signals": "^1.2.3",
"@prefresh/vite": "^2.4.5",
Expand Down Expand Up @@ -79,7 +79,6 @@
"lint-staged": "^10.4.0",
"mochette": "^1.0.1",
"mri": "^1.2.0",
"playwright-chromium": "^1.49.0",
"preact": "^10.25.1",
"prettier": "^3.2.5",
"tar": "^6.1.11",
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/10/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function getHookState(
// useContext
if (type === HookType.useContext) {
const context = list[index]._context || list[index].__c || list[index].c;
const provider = c.context[context._id] || c.context[context.__c];
const provider = c.context[context._id] || c.context[context.__c] || c.context[context.__l];
return provider
? provider.props.value
: context._defaultValue || context.__;
Expand Down Expand Up @@ -212,7 +212,7 @@ export function getDisplayName(vnode: VNode, config: RendererConfig): string {

// Provider
if ((c as any).sub) {
const ctx = (type as any)._contextRef || (type as any).__;
const ctx = (type as any)._contextRef || (type as any).__ || (type as any).__c;
if (ctx && ctx.displayName) {
return `${ctx.displayName}.Provider`;
}
Expand Down
Loading

0 comments on commit 5f94f09

Please sign in to comment.