@servicetitan/ko-bridge
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -14,2 +14,8 @@ import React from 'react'; | ||
private origVisibility?; | ||
componentDidMount(): void; | ||
shouldComponentUpdate(nextProps: KnockoutComponentProps): boolean; | ||
getSnapshotBeforeUpdate(): null; | ||
componentDidUpdate(): void; | ||
componentWillUnmount(): void; | ||
render(): JSX.Element; | ||
private isModelValid; | ||
@@ -21,9 +27,3 @@ private initNode; | ||
private applyBinding; | ||
componentDidMount(): void; | ||
getSnapshotBeforeUpdate(): null; | ||
componentDidUpdate(): void; | ||
componentWillUnmount(): void; | ||
shouldComponentUpdate(nextProps: KnockoutComponentProps): boolean; | ||
render(): JSX.Element; | ||
} | ||
export {}; |
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable no-console */ | ||
var react_1 = __importDefault(require("react")); | ||
@@ -30,2 +31,37 @@ var KnockoutComponent = /** @class */ (function (_super) { | ||
} | ||
KnockoutComponent.prototype.componentDidMount = function () { | ||
this.initNode(); | ||
this.initOrigVisibility(); | ||
this.applyBinding(); | ||
this.updateNodeVisibility(); | ||
}; | ||
KnockoutComponent.prototype.shouldComponentUpdate = function (nextProps) { | ||
if (this.props.koTemplate !== nextProps.koTemplate) { | ||
console.error("Knockout template can't be changed during component life cycle."); | ||
return false; | ||
} | ||
if (this.isBindingApplied && this.props.koModel !== nextProps.koModel) { | ||
if (!this.props.dangerouslyUpdatable) { | ||
console.error("\n Knockout model can't be changed after it's applied.\n If you really need it to be reapplied set dangerouslyUpdatable prop to true.\n Make sure that you know the risks.\n "); | ||
return false; | ||
} | ||
return true; | ||
} | ||
return !this.isBindingApplied && this.props.koModel !== nextProps.koModel; | ||
}; | ||
KnockoutComponent.prototype.getSnapshotBeforeUpdate = function () { | ||
this.cleanNode(); | ||
return null; | ||
}; | ||
KnockoutComponent.prototype.componentDidUpdate = function () { | ||
this.applyBinding(); | ||
this.updateNodeVisibility(); | ||
}; | ||
KnockoutComponent.prototype.componentWillUnmount = function () { | ||
this.cleanNode(); | ||
}; | ||
KnockoutComponent.prototype.render = function () { | ||
var KoTemplate = this.props.koTemplate; | ||
return react_1.default.createElement(KoTemplate, { ref: this.ref }); | ||
}; | ||
KnockoutComponent.prototype.isModelValid = function (koModel) { | ||
@@ -56,3 +92,5 @@ return koModel !== undefined; | ||
KnockoutComponent.prototype.applyBinding = function () { | ||
var koModel = this.props.hasOwnProperty('koModel') ? this.props.koModel : null; | ||
var koModel = Object.prototype.hasOwnProperty.call(this.props, 'koModel') | ||
? this.props.koModel | ||
: null; | ||
if (this.isModelValid(koModel)) { | ||
@@ -63,37 +101,2 @@ ko.applyBindings(koModel, this.node); | ||
}; | ||
KnockoutComponent.prototype.componentDidMount = function () { | ||
this.initNode(); | ||
this.initOrigVisibility(); | ||
this.applyBinding(); | ||
this.updateNodeVisibility(); | ||
}; | ||
KnockoutComponent.prototype.getSnapshotBeforeUpdate = function () { | ||
this.cleanNode(); | ||
return null; | ||
}; | ||
KnockoutComponent.prototype.componentDidUpdate = function () { | ||
this.applyBinding(); | ||
this.updateNodeVisibility(); | ||
}; | ||
KnockoutComponent.prototype.componentWillUnmount = function () { | ||
this.cleanNode(); | ||
}; | ||
KnockoutComponent.prototype.shouldComponentUpdate = function (nextProps) { | ||
if (this.props.koTemplate !== nextProps.koTemplate) { | ||
console.error("Knockout template can't be changed during component life cycle."); | ||
return false; | ||
} | ||
if (this.isBindingApplied && this.props.koModel !== nextProps.koModel) { | ||
if (!this.props.dangerouslyUpdatable) { | ||
console.error("\n Knockout model can't be changed after it's applied.\n If you really need it to be reapplied set dangerouslyUpdatable prop to true.\n Make sure that you know the risks.\n "); | ||
return false; | ||
} | ||
return true; | ||
} | ||
return !this.isBindingApplied && this.props.koModel !== nextProps.koModel; | ||
}; | ||
KnockoutComponent.prototype.render = function () { | ||
var KoTemplate = this.props.koTemplate; | ||
return react_1.default.createElement(KoTemplate, { ref: this.ref }); | ||
}; | ||
KnockoutComponent.defaultProps = { | ||
@@ -100,0 +103,0 @@ dangerouslyUpdatable: false |
{ | ||
"name": "@servicetitan/ko-bridge", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "", | ||
@@ -33,3 +33,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "fc494677f05c4cd9576b9baf556b5af4e3023c3f" | ||
"gitHead": "815ec442266b02c15d043b132ce4904cc5dac03a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
33372
680
0