This repository has been archived by the owner on Jul 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Add evented Node handler to meta #666
Merged
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
838903a
th progress
tomdye ed9bc3e
dimensions tests
tomdye 6f75f56
fixed tests
tomdye f61028d
fixed interface comments
tomdye 8aa52fe
fixed Matches
tomdye 2bb5260
comments
tomdye 35ca787
remove beforeRender
tomdye 66b4d05
pr comments
tomdye 2d4e39f
fix typings
tomdye 47b4f75
add nodeEvent typing
tomdye 0162789
rename Type enum
tomdye 43ab419
rename Type enum
tomdye ea370b8
pr comments, changed dimensions implementation
tomdye 1142321
added getnode function
tomdye 076085d
updated tests
tomdye 4d31f7d
adding integration test
tomdye 5decea2
integration tests
tomdye 0aa14cc
uncomment tests
tomdye e88241b
fix test after changed functionality
tomdye fda32dd
remove cancel raf
tomdye b9787b5
pr nits
tomdye 3e50f14
pr alignment
tomdye 6207249
change to weakmaps
tomdye 1e7cbd6
uncomment tests
tomdye 5fdcf8b
move projector emit, remove event typing, revert maps
tomdye b067ace
pr comments
tomdye 2e80508
pr comments
tomdye 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
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 |
---|---|---|
|
@@ -22,8 +22,7 @@ import { | |
WidgetMetaConstructor, | ||
WidgetBaseConstructor, | ||
WidgetBaseInterface, | ||
WidgetProperties, | ||
ProjectorRenderedEvent | ||
WidgetProperties | ||
} from './interfaces'; | ||
import RegistryHandler from './RegistryHandler'; | ||
import NodeHandler from './NodeHandler'; | ||
|
@@ -102,16 +101,6 @@ export function diffProperty(propertyName: string, diffFunction: DiffPropertyFun | |
}); | ||
} | ||
|
||
/** | ||
* WeakMap containing the current root node number | ||
*/ | ||
export const currentRootNodeMap = new WeakMap<WidgetBase, number>(); | ||
|
||
/** | ||
* Weakmap containing the number of root nodes | ||
*/ | ||
export const numRootNodesMap = new WeakMap<WidgetBase, number>(); | ||
|
||
/** | ||
* Generic decorator handler to take care of whether or not the decorator was called at the class level | ||
* or the method level. | ||
|
@@ -200,6 +189,9 @@ export class WidgetBase<P = WidgetProperties, C extends DNode = DNode> extends E | |
|
||
private _projectorAttachEvent: Handle; | ||
|
||
private _currentRootNode = 0; | ||
private _numRootNodes = 0; | ||
|
||
/** | ||
* @constructor | ||
*/ | ||
|
@@ -251,7 +243,7 @@ export class WidgetBase<P = WidgetProperties, C extends DNode = DNode> extends E | |
this.onElementCreated(element, String(properties.key)); | ||
} | ||
|
||
protected afterRootCreateCallback( | ||
private afterRootCreateCallback( | ||
element: HTMLElement, | ||
projectionOptions: ProjectionOptions, | ||
vnodeSelector: string, | ||
|
@@ -274,7 +266,7 @@ export class WidgetBase<P = WidgetProperties, C extends DNode = DNode> extends E | |
this.onElementUpdated(element, String(properties.key)); | ||
} | ||
|
||
protected afterRootUpdateCallback( | ||
private afterRootUpdateCallback( | ||
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. needs the |
||
element: HTMLElement, | ||
projectionOptions: ProjectionOptions, | ||
vnodeSelector: string, | ||
|
@@ -285,18 +277,13 @@ export class WidgetBase<P = WidgetProperties, C extends DNode = DNode> extends E | |
} | ||
|
||
private _addElementToNodeHandler(element: HTMLElement, projectionOptions: ProjectionOptions, properties: VNodeProperties) { | ||
let currentRootNode = currentRootNodeMap.get(this) || 0; | ||
const numRootNodes = numRootNodesMap.get(this); | ||
|
||
currentRootNode += 1; | ||
currentRootNodeMap.set(this, currentRootNode); | ||
const isLastRootNode = (currentRootNode === numRootNodes); | ||
this._currentRootNode += 1; | ||
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. why not |
||
const isLastRootNode = (this._currentRootNode === this._numRootNodes); | ||
|
||
if (this._projectorAttachEvent === undefined) { | ||
this._projectorAttachEvent = projectionOptions.nodeEvent.on('rendered', | ||
({ element, properties }: ProjectorRenderedEvent) => { | ||
this._nodeHandler.addProjector(element, properties); | ||
}); | ||
this._projectorAttachEvent = projectionOptions.nodeEvent.on('rendered', () => { | ||
this._nodeHandler.addProjector(); | ||
}); | ||
this.own(this._projectorAttachEvent); | ||
} | ||
|
||
|
@@ -475,8 +462,8 @@ export class WidgetBase<P = WidgetProperties, C extends DNode = DNode> extends E | |
private _decorateNodes(node: DNode | DNode[]) { | ||
let nodes = Array.isArray(node) ? [ ...node ] : [ node ]; | ||
|
||
numRootNodesMap.set(this, nodes.length); | ||
currentRootNodeMap.set(this, 0); | ||
this._numRootNodes = nodes.length; | ||
this._currentRootNode = 0; | ||
const rootNodes: DNode[] = []; | ||
|
||
nodes.forEach(node => { | ||
|
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
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
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.
needs the
_
prefix