FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow link to receive owner directly by NullVoxPopuli · Pull Request #38 · universal-ember/reactiveweb · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .json  (1) .ts  (2) .yaml  (1) All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 9 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions reactiveweb/src/link.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ function directLink(child: object, parent: object) {

let owner = getOwner(parent);

// the parent *is* the owner
// These checks are based on the `@public` interface of what
// an owner is
if (!owner && 'lookup' in parent && 'register' in parent && 'ownerInjection' in parent) {
// SAFETY: there is no JS-mode way to narrow an object
// to an owner.
// SEE: @ember/-internal/owner.d.ts
owner = parent as any;
}

if (owner) {
setOwner(child, owner);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test-app/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"lint:prettier": "prettier -c .",
"lint:prettier:fix": "prettier -w .",
"_syncPnpm": "pnpm sync-dependencies-meta-injected",
"start": "concurrently 'ember serve' 'pnpm _syncPnpm --watch' --names 'tests serve,tests sync deps'",
"start": "concurrently 'ember serve' 'pnpm sync-dependencies-meta-injected --watch' --names 'tests serve,tests sync deps'",
"test:ember": "pnpm _syncPnpm && ember test --test-port 0"
},
"dependenciesMeta": {
Expand Down Expand Up @@ -82,7 +82,6 @@
"prettier": "^3.0.3",
"qunit": "^2.20.0",
"qunit-dom": "^3.0.0",
"reactiveweb": "workspace:*",
"stylelint": "^15.11.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-prettier": "^4.0.2",
Expand All @@ -101,6 +100,7 @@
"@nullvoxpopuli/eslint-configs": "^3.2.2",
"ember-concurrency": "^3.1.1",
"ember-resources": "^6.4.2",
"reactiveweb": "workspace:*",
"msw": "^1.3.2"
},
"msw": {
Expand Down
14 changes: 14 additions & 0 deletions tests/test-app/tests/utils/link-test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,18 @@ module('link', function (hooks) {

assert.strictEqual(demo.foo.foo, 2);
});

test('can be passed the owner', async function (assert) {
this.owner.register('service:foo', FooService);

class Demo {
@service declare foo: FooService;
}

let demo = new Demo();

link(demo, this.owner);

assert.strictEqual(demo.foo.foo, 2);
});
});

Back | FazBrowse Home | New Git URL