Comparing version 0.4.3 to 0.5.0
@@ -0,0 +0,0 @@ import Graph from '../graph/Graph'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export declare function array<T>(target: any, propertyKey: string): any; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -20,2 +20,3 @@ import VirtualNode from './VirtualNode'; | ||
rendered: boolean; | ||
portal: boolean; | ||
constructor(props?: T & IVirtualNodeProps, ...children: any[]); | ||
@@ -35,3 +36,3 @@ storeProps(props?: T & IVirtualNodeProps, ...children: any[]): void; | ||
diffFragments(newRootComponentNode: ComponentNode<IVirtualNodeProps>, oldRootComponentNode: ComponentNode<IVirtualNodeProps>, oldElement: Node, namespace: string, offsetIndex?: number): Node; | ||
diffComponents(newRootComponentNode: ComponentNode<IVirtualNodeProps>, oldRootComponentNode: ComponentNode<IVirtualNodeProps>, oldElement: Node, namespace: string): Node; | ||
diffComponents(newRootComponentNode: ComponentNode<IVirtualNodeProps>, oldRootComponentNode: ComponentNode<IVirtualNodeProps>, namespace: string): Node; | ||
diffVirtualNodes(newRoot: VirtualNode<IVirtualNodeProps>, oldRoot: VirtualNode<IVirtualNodeProps>, oldElement: HTMLElement, namespace: string, offsetIndex?: number): HTMLElement; | ||
@@ -38,0 +39,0 @@ getChildLength(): any; |
@@ -15,2 +15,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
this.rendered = false; | ||
this.portal = false; | ||
this.uniqueId = Math.floor(Math.random() * 1000000); | ||
@@ -98,3 +99,4 @@ this.storeProps(props, ...children); | ||
else { | ||
element = this.diffComponents(root, oldRoot, oldElement, namespace); | ||
element = this.diffComponents(root, oldRoot, namespace); | ||
swapChildren(element, oldElement); | ||
} | ||
@@ -167,2 +169,5 @@ noDispose = true; | ||
this.mounted = true; | ||
if (this.portal) { | ||
element = document.createComment('Empty Component'); | ||
} | ||
return element; | ||
@@ -206,8 +211,12 @@ } | ||
} | ||
diffComponents(newRootComponentNode, oldRootComponentNode, oldElement, namespace) { | ||
diffComponents(newRootComponentNode, oldRootComponentNode, namespace) { | ||
if (newRootComponentNode === oldRootComponentNode) { | ||
return oldRootComponentNode.component.element; | ||
} | ||
if (newRootComponentNode.component) { | ||
return newRootComponentNode.component.element; | ||
} | ||
var output; | ||
let oldRoot = oldRootComponentNode.component; | ||
if (newRootComponentNode === oldRootComponentNode) { | ||
return oldElement; | ||
} | ||
let oldElement = oldRoot.element; | ||
if (!oldRoot) { | ||
@@ -248,3 +257,4 @@ throw 'Old Component has never been rendered. Replacing with new Component.'; | ||
else { | ||
output = this.diffComponents(innerRoot, innerOldRoot, oldElement, namespace); | ||
output = this.diffComponents(innerRoot, innerOldRoot, namespace); | ||
swapChildren(output, oldElement); | ||
} | ||
@@ -295,6 +305,6 @@ } | ||
} | ||
if (output !== oldElement && oldElement && oldElement.parentNode) { | ||
oldElement.parentNode.replaceChild(output, oldElement); | ||
oldRoot.element = output; | ||
if (oldRoot.portal) { | ||
output = document.createComment('Empty Component'); | ||
} | ||
oldRoot.element = output; | ||
return output; | ||
@@ -340,3 +350,4 @@ } | ||
else { | ||
this.diffComponents(newChild, oldChild, oldElement.childNodes[childIndex], namespace); | ||
let newNode = this.diffComponents(newChild, oldChild, namespace); | ||
swapChildren(newNode, oldElement.childNodes[childIndex], oldElement, childIndex); | ||
} | ||
@@ -448,2 +459,19 @@ } | ||
} | ||
function swapChildren(newNode, oldNode, parent, index) { | ||
if (newNode) { | ||
if (newNode !== oldNode) { | ||
if (oldNode && oldNode.parentNode) { | ||
oldNode.parentNode.replaceChild(newNode, oldNode); | ||
} | ||
else if (parent) { | ||
parent.insertBefore(newNode, parent.childNodes[index + 1]); | ||
} | ||
} | ||
} | ||
else { | ||
if (oldNode && oldNode.parentNode) { | ||
oldNode.parentNode.removeChild(oldNode); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=Component.js.map |
@@ -0,0 +0,0 @@ import { IVirtualNode, IVirtualNodeProps } from './IVirtualNode'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import { IVirtualNode, IVirtualNodeProps } from './IVirtualNode'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export interface IVirtualNodeProps { |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=IVirtualNode.js.map |
@@ -0,0 +0,0 @@ import { IVirtualNode, IVirtualElementProps } from './IVirtualNode'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import { IObservable, ISubscriber } from './IObservable'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import Computed from './Computed'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import { IObservable, ISubscriber, ISubscriberFunction } from './IObservable'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export interface ISubscriber { |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=IObservable.js.map |
@@ -0,0 +0,0 @@ import { IObservable, ISubscriber, ISubscriberFunction } from './IObservable'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import Observable from './Observable'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import Observable from './Observable'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import Observable from './Observable'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import { IVirtualNodeProps } from '../dom/IVirtualNode'; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=Elements.js.map |
@@ -0,0 +0,0 @@ import { IVirtualNodeProps } from '../modules/Cascade'; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=HTMLElements.js.map |
@@ -0,0 +0,0 @@ import { IVirtualNode, IVirtualNodeProps } from '../dom/IVirtualNode'; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=JSX.js.map |
@@ -0,0 +0,0 @@ import { IVirtualNodeProps } from '../modules/Cascade'; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=SVGElements.js.map |
@@ -15,2 +15,3 @@ import '../jsx/JSX'; | ||
export { Component } from '../dom/Component'; | ||
export { default as Portal } from '../dom/Portal'; | ||
export { default as DecoratorUtil, ObservableFactory } from '../util/DecoratorUtil'; | ||
@@ -17,0 +18,0 @@ export { observable, computed, array, hash } from '../cascade/Decorators'; |
@@ -23,2 +23,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Component = Component_1.Component; | ||
var Portal_1 = require("../dom/Portal"); | ||
exports.Portal = Portal_1.default; | ||
var DecoratorUtil_1 = require("../util/DecoratorUtil"); | ||
@@ -25,0 +27,0 @@ exports.DecoratorUtil = DecoratorUtil_1.default; |
@@ -0,0 +0,0 @@ import { IObservable } from '../modules/Cascade'; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export default class Diff { |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
export declare function wait(time: number): Promise<{}>; |
@@ -0,0 +0,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "cascade", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"description": "A modern library for creating user interfaces.", | ||
@@ -32,4 +32,4 @@ "author": "Sean Johnson <sjohnson@sjohnsonaz.com>", | ||
"devDependencies": { | ||
"@types/chai": "4.1.3", | ||
"@types/mocha": "5.2.1", | ||
"@types/chai": "4.1.4", | ||
"@types/mocha": "5.2.3", | ||
"chai": "4.1.2", | ||
@@ -41,7 +41,7 @@ "es6-shim": "0.35.3", | ||
"rimraf": "2.6.2", | ||
"ts-loader": "4.4.1", | ||
"ts-loader": "4.4.2", | ||
"typedoc": "0.11.1", | ||
"typescript": "2.9.1", | ||
"webpack": "4.12.0", | ||
"webpack-cli": "3.0.3" | ||
"typescript": "2.9.2", | ||
"webpack": "4.13.0", | ||
"webpack-cli": "3.0.8" | ||
}, | ||
@@ -48,0 +48,0 @@ "keywords": [ |
@@ -0,0 +0,0 @@ # Cascade |
@@ -29,2 +29,3 @@ /// <reference path="../../node_modules/@types/mocha/index.d.ts" /> | ||
import '../tests/Cascade.render_Component_Test'; | ||
import '../tests/Component.portal_Test'; | ||
import '../tests/cascadeTest1'; | ||
@@ -40,2 +41,3 @@ import '../tests/cascadeTest2'; | ||
import '../tests/Component.diff_Test'; | ||
import '../tests/Component.diff_Nested_Children_Test'; | ||
import '../tests/Component.dispose_Test'; | ||
@@ -42,0 +44,0 @@ import '../tests/Component.toNode_Test'; |
@@ -0,0 +0,0 @@ var jsdom = require('jsdom'); |
@@ -0,0 +0,0 @@ var fs = require('fs'); |
@@ -0,0 +0,0 @@ // TODO: Remove Proxy check |
@@ -0,0 +0,0 @@ import Cascade from './Cascade'; |
@@ -32,2 +32,3 @@ import Cascade from '../cascade/Cascade'; | ||
rendered: boolean = false; | ||
portal: boolean = false; | ||
@@ -150,3 +151,4 @@ constructor(props?: T & IVirtualNodeProps, ...children: any[]) { | ||
} else { | ||
element = this.diffComponents(root, oldRoot, oldElement, namespace); | ||
element = this.diffComponents(root, oldRoot, namespace); | ||
swapChildren(element, oldElement); | ||
} | ||
@@ -232,2 +234,7 @@ noDispose = true; | ||
this.mounted = true; | ||
if (this.portal) { | ||
element = document.createComment('Empty Component'); | ||
} | ||
return element; | ||
@@ -285,11 +292,19 @@ } | ||
diffComponents(newRootComponentNode: ComponentNode<IVirtualNodeProps>, oldRootComponentNode: ComponentNode<IVirtualNodeProps>, oldElement: Node, namespace: string) { | ||
diffComponents(newRootComponentNode: ComponentNode<IVirtualNodeProps>, oldRootComponentNode: ComponentNode<IVirtualNodeProps>, namespace: string) { | ||
// No diff necessary. We have the exact same Components | ||
if (newRootComponentNode === oldRootComponentNode) { | ||
return oldRootComponentNode.component.element; | ||
} | ||
// We have already rendered newRootComponentNode. It is likely a child Component. | ||
if (newRootComponentNode.component) { | ||
return newRootComponentNode.component.element; | ||
} | ||
var output: Node; | ||
let oldRoot = oldRootComponentNode.component; | ||
if (newRootComponentNode === oldRootComponentNode) { | ||
// No diff necessary. We have the exact same Components | ||
return oldElement; | ||
} | ||
let oldElement = oldRoot.element; | ||
// This should never happen | ||
if (!oldRoot) { | ||
// This should never happen | ||
throw 'Old Component has never been rendered. Replacing with new Component.'; | ||
@@ -333,3 +348,4 @@ } | ||
} else { | ||
output = this.diffComponents(innerRoot, innerOldRoot, oldElement, namespace); | ||
output = this.diffComponents(innerRoot, innerOldRoot, namespace); | ||
swapChildren(output, oldElement); | ||
} | ||
@@ -390,9 +406,8 @@ } else { | ||
// Swap root elements if necessary | ||
if (output !== oldElement && oldElement && oldElement.parentNode) { | ||
oldElement.parentNode.replaceChild(output, oldElement); | ||
oldRoot.element = output; | ||
if (oldRoot.portal) { | ||
output = document.createComment('Empty Component'); | ||
} | ||
oldRoot.element = output; | ||
return output; | ||
@@ -442,3 +457,4 @@ } | ||
} else { | ||
this.diffComponents(newChild, oldChild, oldElement.childNodes[childIndex] as HTMLElement, namespace); | ||
let newNode = this.diffComponents(newChild, oldChild, namespace); | ||
swapChildren(newNode, oldElement.childNodes[childIndex] as HTMLElement, oldElement, childIndex); | ||
} | ||
@@ -562,1 +578,17 @@ } else if (newChild instanceof VirtualNode) { | ||
} | ||
function swapChildren(newNode: Node, oldNode: Node, parent?: HTMLElement, index?: number) { | ||
if (newNode) { | ||
if (newNode !== oldNode) { | ||
if (oldNode && oldNode.parentNode) { | ||
oldNode.parentNode.replaceChild(newNode, oldNode); | ||
} else if (parent) { | ||
parent.insertBefore(newNode, parent.childNodes[index + 1]); | ||
} | ||
} | ||
} else { | ||
if (oldNode && oldNode.parentNode) { | ||
oldNode.parentNode.removeChild(oldNode); | ||
} | ||
} | ||
} |
@@ -0,0 +0,0 @@ import { IVirtualNode, IVirtualNodeProps } from './IVirtualNode'; |
@@ -0,0 +0,0 @@ import VirtualNode from './VirtualNode'; |
@@ -0,0 +0,0 @@ export interface IVirtualNodeProps { |
@@ -0,0 +0,0 @@ import { IVirtualNode, IVirtualElementProps } from './IVirtualNode'; |
@@ -0,0 +0,0 @@ import { IObservable, ISubscriber } from './IObservable'; |
@@ -0,0 +0,0 @@ import Computed from './Computed'; |
@@ -0,0 +0,0 @@ import { IObservable, ISubscriber, ISubscriberFunction } from './IObservable'; |
@@ -0,0 +0,0 @@ export interface ISubscriber { |
@@ -0,0 +0,0 @@ import { IObservable, ISubscriber, ISubscriberFunction } from './IObservable'; |
@@ -0,0 +0,0 @@ declare var Proxy: any; |
@@ -0,0 +0,0 @@ import Observable from './Observable'; |
@@ -0,0 +0,0 @@ declare var Proxy: any; |
@@ -0,0 +0,0 @@ import { IVirtualNodeProps } from '../dom/IVirtualNode'; |
@@ -0,0 +0,0 @@ import { IVirtualNodeProps } from '../modules/Cascade'; |
@@ -0,0 +0,0 @@ import { IVirtualNode, IVirtualNodeProps } from '../dom/IVirtualNode'; |
@@ -0,0 +0,0 @@ import { IVirtualNodeProps } from '../modules/Cascade'; |
@@ -18,2 +18,3 @@ import '../jsx/JSX'; | ||
export { Component } from '../dom/Component'; | ||
export { default as Portal } from '../dom/Portal'; | ||
@@ -20,0 +21,0 @@ export { default as DecoratorUtil, ObservableFactory } from '../util/DecoratorUtil'; |
@@ -0,0 +0,0 @@ import Cascade, { IObservable, Computed } from '../modules/Cascade'; |
@@ -0,0 +0,0 @@ export default class Diff { |
@@ -0,0 +0,0 @@ export function wait(time: number) { |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
@@ -0,0 +0,0 @@ import { expect } from 'chai'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122
10552
385134