-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #1484 [Live] Fixed idiomorph id child handling & JavaScript c…
…leanup (weaverryan) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Live] Fixed idiomorph id child handling & JavaScript cleanup | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | Issues | Fix #1470 Fix #1472 | License | MIT Hi! TODO: * [x] Finish fixing minor js tests Sorry, quite a lot going on here to get morphing & child rendering *just* right after switching to Idiomorph. The referenced tickets exposed a few cases that were not handled by the tests: ## IMPORTANT CHANGES * A) `data-live-id` is now `id`. That's because Idiomorph uses `id` as its special key. So it's time to embrace that. * B) Fixed a bug if `ChildComponentA` were changed to `ChildComponentB` in the same location. Under some situations, we would NOT swap for the new HTML, and would instead "refresh" `ChildComponentA`. * C) In the above situation, even when we DID swap to `ChildComponentB` correctly, the `LiveController` would still be attached to a `Component` object representing `ChildComponentA`. That would cause problems later on. We now watch for the `id` attribute to change, and then re-create a new `Component` if changed. * D) Removed special "morph" handling for children components (which are always empty). Instead added a new `data-live-preserve` attribute for elements that want to keep their current element. Improved handling of this. ## OTHER CHANGES * Various internal attributes like `data-live-emit` were changed to Stimulus values, like `data-events-to-emit-value`. These are not attributes the user ever sets directly. * Moved the remaining JS child handling into a plugin * Added `morph:started` and `morph:finished` * Simplified "child" handling. Previously we really tried to keep track of our children as they were attached / detached. Now, if we need to know our children, we loop over all components to find children. Cheers! Commits ------- 6d59382 [Live] Fixed idiomorph id child handling & JavaScript cleanup
- Loading branch information
Showing
48 changed files
with
1,081 additions
and
974 deletions.
There are no files selected for viewing
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
21 changes: 10 additions & 11 deletions
21
src/LiveComponent/assets/dist/Component/ElementDriver.d.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
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
11 changes: 11 additions & 0 deletions
11
src/LiveComponent/assets/dist/Component/plugins/ChildComponentPlugin.d.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Component from '../../Component'; | ||
import { PluginInterface } from './PluginInterface'; | ||
export default class implements PluginInterface { | ||
private readonly component; | ||
private parentModelBindings; | ||
constructor(component: Component); | ||
attachToComponent(component: Component): void; | ||
private getChildrenFingerprints; | ||
private notifyParentModelChange; | ||
private getChildren; | ||
} |
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,9 +1,8 @@ | ||
import Component from './Component'; | ||
export default class { | ||
private componentMapByElement; | ||
private componentMapByComponent; | ||
registerComponent(element: HTMLElement, component: Component): void; | ||
unregisterComponent(component: Component): void; | ||
getComponent(element: HTMLElement): Promise<Component>; | ||
findComponents(currentComponent: Component, onlyParents: boolean, onlyMatchName: string | null): Component[]; | ||
} | ||
export declare const resetRegistry: () => void; | ||
export declare const registerComponent: (component: Component) => void; | ||
export declare const unregisterComponent: (component: Component) => void; | ||
export declare const getComponent: (element: HTMLElement) => Promise<Component>; | ||
export declare const findComponents: (currentComponent: Component, onlyParents: boolean, onlyMatchName: string | null) => Component[]; | ||
export declare const findChildren: (currentComponent: Component) => Component[]; | ||
export declare const findParent: (currentComponent: Component) => Component | null; |
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 @@ | ||
export default function getElementAsTagText(element: HTMLElement): string; |
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
Oops, something went wrong.