-
-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove code for pre-ember-v4 #1382
Merged
MelSumner
merged 10 commits into
emberjs:master
from
NullVoxPopuli:remove-code-for-pre-ember-v4
May 31, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e5dc747
Remove code for pre-ember-v4
NullVoxPopuli 162a6c5
Add @glimmer/manager *just for types* to devDependencies
NullVoxPopuli c453f8c
Fix the TS error
NullVoxPopuli 6267efe
Update setup-rendering-context given the upstream changes
NullVoxPopuli fb70f63
Revert package / dep changes, so I can commit only what is needed wit…
NullVoxPopuli 7ed34b4
Add @glimmer/manager (for types) because we import it, and we need th…
NullVoxPopuli 71e75fd
Upgrade the other glimmer dependencies, for their types, because addi…
NullVoxPopuli 62a7da4
Undo the dependency changes, and declare a .d.ts entry for @glimmer/m…
NullVoxPopuli f5e18a5
Remove SAFETY hack introduced due to (mistakenly) adding @glimmer/man…
NullVoxPopuli 977228b
Absorb change in @glimmer/manager behavior within is-component
NullVoxPopuli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 1 addition & 36 deletions
37
addon/addon-test-support/@ember/test-helpers/-internal/get-component-manager.ts
This file contains 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 |
---|---|---|
@@ -1,38 +1,3 @@ | ||
import Ember from 'ember'; | ||
import { | ||
macroCondition, | ||
importSync, | ||
dependencySatisfies, | ||
} from '@embroider/macros'; | ||
|
||
let getComponentManager: (definition: object, owner: object) => unknown; | ||
|
||
if (macroCondition(dependencySatisfies('ember-source', '>=3.27.0-alpha.1'))) { | ||
let _getComponentManager = | ||
//@ts-ignore | ||
importSync('@glimmer/manager').getInternalComponentManager; | ||
|
||
getComponentManager = (definition: object, owner: object) => { | ||
return _getComponentManager(definition, true); | ||
}; | ||
} else if ( | ||
macroCondition(dependencySatisfies('ember-source', '>=3.25.0-beta.1')) | ||
) { | ||
let _getComponentManager = (Ember as any).__loader.require( | ||
'@glimmer/manager' | ||
).getInternalComponentManager; | ||
|
||
getComponentManager = (definition: object, owner: object) => { | ||
return _getComponentManager(definition, true); | ||
}; | ||
} else { | ||
let _getComponentManager = (Ember as any).__loader.require( | ||
'@glimmer/runtime' | ||
).getComponentManager; | ||
|
||
getComponentManager = (definition: object, owner: object) => { | ||
return _getComponentManager(owner, definition); | ||
}; | ||
} | ||
import { getInternalComponentManager as getComponentManager } from '@glimmer/manager'; | ||
|
||
export default getComponentManager; |
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -17,7 +17,6 @@ import { assert } from '@ember/debug'; | |
import { runHooks } from './helper-hooks'; | ||
import hasEmberVersion from './has-ember-version'; | ||
import isComponent from './-internal/is-component'; | ||
import { macroCondition, dependencySatisfies } from '@embroider/macros'; | ||
import { ComponentRenderMap, SetUsage } from './setup-context'; | ||
|
||
const OUTLET_TEMPLATE = hbs`{{outlet}}`; | ||
|
@@ -129,55 +128,33 @@ export function render( | |
let OutletTemplate = lookupOutletTemplate(owner); | ||
let ownerToRenderFrom = options?.owner || owner; | ||
|
||
if (macroCondition(dependencySatisfies('ember-source', '<3.24.0'))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code change is the removal of this if branch, keeping only the else |
||
// Pre 3.24, we just don't support rendering components at all, so we error | ||
// if we find anything that isn't a template. | ||
const isTemplate = | ||
('__id' in templateOrComponent && '__meta' in templateOrComponent) || | ||
('id' in templateOrComponent && 'meta' in templateOrComponent); | ||
if (isComponent(templateOrComponent, owner)) { | ||
// We use this to track when `render` is used with a component so that we can throw an | ||
// assertion if `this.{set,setProperty} is used in the same test | ||
ComponentRenderMap.set(context, true); | ||
|
||
if (!isTemplate) { | ||
throw new Error( | ||
`Using \`render\` with something other than a pre-compiled template is not supported until Ember 3.24 (you are on ${Ember.VERSION}).` | ||
const setCalls = SetUsage.get(context); | ||
|
||
if (setCalls !== undefined) { | ||
assert( | ||
`You cannot call \`this.set\` or \`this.setProperties\` when passing a component to \`render\`, but they were called for the following properties:\n${setCalls | ||
.map((key) => ` - ${key}`) | ||
.join('\n')}` | ||
); | ||
} | ||
|
||
context = { | ||
ProvidedComponent: templateOrComponent, | ||
}; | ||
templateOrComponent = INVOKE_PROVIDED_COMPONENT; | ||
} else { | ||
templateId += 1; | ||
let templateFullName = `template:-undertest-${templateId}` as const; | ||
ownerToRenderFrom.register(templateFullName, templateOrComponent); | ||
templateOrComponent = lookupTemplate( | ||
ownerToRenderFrom, | ||
templateFullName | ||
); | ||
} else { | ||
if (isComponent(templateOrComponent, owner)) { | ||
// We use this to track when `render` is used with a component so that we can throw an | ||
// assertion if `this.{set,setProperty} is used in the same test | ||
ComponentRenderMap.set(context, true); | ||
|
||
const setCalls = SetUsage.get(context); | ||
|
||
if (setCalls !== undefined) { | ||
assert( | ||
`You cannot call \`this.set\` or \`this.setProperties\` when passing a component to \`render\`, but they were called for the following properties:\n${setCalls | ||
.map((key) => ` - ${key}`) | ||
.join('\n')}` | ||
); | ||
} | ||
|
||
context = { | ||
ProvidedComponent: templateOrComponent, | ||
}; | ||
templateOrComponent = INVOKE_PROVIDED_COMPONENT; | ||
} else { | ||
templateId += 1; | ||
let templateFullName = `template:-undertest-${templateId}` as const; | ||
ownerToRenderFrom.register(templateFullName, templateOrComponent); | ||
templateOrComponent = lookupTemplate( | ||
ownerToRenderFrom, | ||
templateFullName | ||
); | ||
} | ||
} | ||
|
||
let outletState = { | ||
|
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module '@glimmer/manager'; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that
@glimmer/manager
changed its behavior. This change absorbs the change in@glimmer/manager