web-component-wrapper 0.0.614 → 0.0.615
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ReactWeb.js +10 -10
- package/dist/Web.js +7 -7
- package/dist/bundle/ReactWeb.js +157 -137
- package/dist/bundle/Web.js +154 -134
- package/dist/bundle/compatible/ReactWeb.js +156 -136
- package/dist/bundle/compatible/Web.js +153 -133
- package/dist/bundle/compatible/decorator.js +147 -127
- package/dist/bundle/compatible/index.js +156 -136
- package/dist/bundle/decorator.js +147 -127
- package/dist/bundle/index.js +158 -138
- package/dist/compatible/ReactWeb.js +9 -9
- package/dist/compatible/Web.js +6 -6
- package/dist/compatible/index.js +9 -9
- package/dist/index.js +11 -11
- package/package.json +12 -12
- package/readme.md +21 -24
|
@@ -274,14 +274,14 @@ try{this.isConnected=false}catch(_unused2){// Ignore error.
|
|
|
274
274
|
* @param domNode - Node to start traversing from.
|
|
275
275
|
* @param scope - Scope to render property value again.
|
|
276
276
|
*/},{key:"applyBinding",value:function applyBinding(domNode,scope){var _this6=this;if(!domNode.getAttributeNames)return;var _iterator4=_createForOfIteratorHelper(domNode.getAttributeNames()),_step4;try{var _loop2=function _loop2(){var attributeName=_step4.value;var name;if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name){var value=domNode.getAttribute(attributeName);if(value===null)return 0;// continue
|
|
277
|
-
if(name.startsWith("attribute-")||name.startsWith("property-")){var evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:scope,binding:domNode});if(evaluated.error){log.warn("Error occurred during processing given","attribute binding \"".concat(attributeName,"\" on node:"),domNode,evaluated.error);return 0;// continue
|
|
277
|
+
if(name.startsWith("attribute-")||name.startsWith("property-")){var evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:scope,binding:domNode});if(evaluated.error){void log.warn("Error occurred during processing given","attribute binding \"".concat(attributeName,"\" on node:"),domNode,evaluated.error);return 0;// continue
|
|
278
278
|
}if(name.startsWith("attribute-"))domNode.setAttribute(name.substring("attribute-".length),evaluated.result);else/*
|
|
279
279
|
NOTE: Cast to "textContent" to have a writable
|
|
280
280
|
property here.
|
|
281
281
|
*/domNode[(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("property-".length))]=evaluated.result}else if(name.startsWith("on-")){name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("on-".length));scope=_objectSpread({log:log,event:undefined,parameters:undefined},scope);/*
|
|
282
282
|
NOTE: We pre-compile event listener since they should
|
|
283
283
|
usually be called more often than binded.
|
|
284
|
-
*/var compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scope,execute:true,binding:domNode});if(compilation.error)log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,compilation.error);else _this6.addSecureEventListener(domNode,name,function(){for(var _len=arguments.length,parameters=new Array(_len),_key=0;_key<_len;_key++){parameters[_key]=arguments[_key]}scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction.apply(compilation,_toConsumableArray(compilation.originalScopeNames.map(function(name){return scope[name]})))}catch(error){log.warn("Error occurred during processing","given event binding","\"".concat(attributeName,"\" on node:"),domNode,"Given expression \"".concat(value,"\" could"),"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+"\": ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)))}})}}},_ret;for(_iterator4.s();!(_step4=_iterator4.n()).done;){_ret=_loop2();if(_ret===0)continue}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}}/**
|
|
284
|
+
*/var compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scope,execute:true,binding:domNode});if(compilation.error)void log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,compilation.error);else _this6.addSecureEventListener(domNode,name,function(){for(var _len=arguments.length,parameters=new Array(_len),_key=0;_key<_len;_key++){parameters[_key]=arguments[_key]}scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction.apply(compilation,_toConsumableArray(compilation.originalScopeNames.map(function(name){return scope[name]})))}catch(error){void log.warn("Error occurred during processing","given event binding","\"".concat(attributeName,"\" on node:"),domNode,"Given expression \"".concat(value,"\" could"),"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+"\": ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)))}})}}},_ret;for(_iterator4.s();!(_step4=_iterator4.n()).done;){_ret=_loop2();if(_ret===0)continue}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}}/**
|
|
285
285
|
* Binds properties and event handler to given, sibling, and nested nodes.
|
|
286
286
|
* @param domNode - Node to start traversing from.
|
|
287
287
|
* @param scope - Scope to render property value again.
|
|
@@ -314,7 +314,7 @@ var currentDomNode=domNode.firstChild;while(currentDomNode){if(!options.filter||
|
|
|
314
314
|
* @param options - Evaluation options.
|
|
315
315
|
* @param scope - Scope to evaluate against.
|
|
316
316
|
* @returns Evaluated string result or null.
|
|
317
|
-
*/},{key:"evaluateCompiledDomNodeTemplate",value:function evaluateCompiledDomNodeTemplate(options,scope){var domNode=options.domNode,error=options.error,templateFunction=options.templateFunction,scopeNames=options.scopeNames;if(!(templateFunction&&scopeNames))return null;if(error){log.warn("Error occurred during compiling node content:",error);return null}var output=null;try{output=templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})))}catch(error){log.warn("Error occurred when \"".concat(this.self._name,"\" is running"),"\"".concat(String(templateFunction),"\": with bound"),"names \"".concat(scopeNames.join("\", \""),"\":"),"\"".concat(error,"\". Rendering node:"),domNode)}return output}/**
|
|
317
|
+
*/},{key:"evaluateCompiledDomNodeTemplate",value:function evaluateCompiledDomNodeTemplate(options,scope){var domNode=options.domNode,error=options.error,templateFunction=options.templateFunction,scopeNames=options.scopeNames;if(!(templateFunction&&scopeNames))return null;if(error){void log.warn("Error occurred during compiling node content:",error);return null}var output=null;try{output=templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})))}catch(error){void log.warn("Error occurred when \"".concat(this.self._name,"\" is running"),"\"".concat(String(templateFunction),"\": with bound"),"names \"".concat(scopeNames.join("\", \""),"\":"),"\"".concat(error,"\". Rendering node:"),domNode)}return output}/**
|
|
318
318
|
* Compiles and evaluates given node content and their children. Replaces
|
|
319
319
|
* each node content with their evaluated representation.
|
|
320
320
|
* @param domNode - Node to evaluate.
|
|
@@ -475,12 +475,12 @@ if(!handled&¶meters.length>0&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isO
|
|
|
475
475
|
* and registers in a property mapping object.
|
|
476
476
|
* @param attributeName - Name of given value.
|
|
477
477
|
* @param value - Value to evaluate.
|
|
478
|
-
*/)},{key:"evaluateStringOrNullAndSetAsProperty",value:function evaluateStringOrNullAndSetAsProperty(attributeName,value){var _this11=this;var preEvaluate=attributeName.startsWith("-");var effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;var name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);var alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){var type=this.self.propertyTypes[name];if(preEvaluate){if(value){var result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:_objectSpread({},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE),binding:this});if(result.error){log.warn("Failed to process pre-evaluation attribute","\"".concat(attributeName,"\": ").concat(result.error,". Will be"),"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{var booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{var error=null;var templateFunction;var scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){var _result3=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=_result3.error;templateFunction=_result3.templateFunction;if(error)log.warn("Failed to compile given handler","\"".concat(attributeName,"\": ").concat(error,"."))}this.setInternalPropertyValue(name,function(){for(var _len4=arguments.length,parameters=new Array(_len4),_key4=0;_key4<_len4;_key4++){parameters[_key4]=arguments[_key4]}if(_this11.outputEventNames.has(name))void _this11.reflectEventToProperties(name,parameters);var result=undefined;if(!error){var scope=_objectSpread({parameters:parameters},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE);for(var _i8=0,_scopeNames=scopeNames;_i8<_scopeNames.length;_i8++){var _name4=_scopeNames[_i8];scope[_name4]=parameters[0]}try{var _templateFunction;result=(_templateFunction=templateFunction)===null||_templateFunction===void 0?void 0:_templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})).concat([parameters,scope],_toConsumableArray(clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(function(name){return clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]}))))}catch(error){log.warn("Failed to evaluate function","\"".concat(attributeName,"\" with expression"),"\"".concat(value,"\" and scope"),"variables","\"".concat(scopeNames.join("\", \""),"\" set to"),"\"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters),"\":"),"".concat(error,". Set property"),"to \"undefined\".")}}if(!_this11.self.renderProperties.includes(name))_this11.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){var evaluated;try{evaluated=JSON.parse(value)}catch(error){log.warn("Error occurred during parsing given json","attribute \"".concat(attributeName,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
|
|
478
|
+
*/)},{key:"evaluateStringOrNullAndSetAsProperty",value:function evaluateStringOrNullAndSetAsProperty(attributeName,value){var _this11=this;var preEvaluate=attributeName.startsWith("-");var effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;var name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);var alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){var type=this.self.propertyTypes[name];if(preEvaluate){if(value){var result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:_objectSpread({},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE),binding:this});if(result.error){void log.warn("Failed to process pre-evaluation attribute","\"".concat(attributeName,"\": ").concat(result.error,". Will be"),"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{var booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{var error=null;var templateFunction;var scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){var _result3=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=_result3.error;templateFunction=_result3.templateFunction;if(error)void log.warn("Failed to compile given handler","\"".concat(attributeName,"\": ").concat(error,"."))}this.setInternalPropertyValue(name,function(){for(var _len4=arguments.length,parameters=new Array(_len4),_key4=0;_key4<_len4;_key4++){parameters[_key4]=arguments[_key4]}if(_this11.outputEventNames.has(name))void _this11.reflectEventToProperties(name,parameters);var result=undefined;if(!error){var scope=_objectSpread({parameters:parameters},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE);for(var _i8=0,_scopeNames=scopeNames;_i8<_scopeNames.length;_i8++){var _name4=_scopeNames[_i8];scope[_name4]=parameters[0]}try{var _templateFunction;result=(_templateFunction=templateFunction)===null||_templateFunction===void 0?void 0:_templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})).concat([parameters,scope],_toConsumableArray(clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(function(name){return clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]}))))}catch(error){void log.warn("Failed to evaluate function","\"".concat(attributeName,"\" with expression"),"\"".concat(value,"\" and scope"),"variables","\"".concat(scopeNames.join("\", \""),"\" set to"),"\"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters),"\":"),"".concat(error,". Set property"),"to \"undefined\".")}}if(!_this11.self.renderProperties.includes(name))_this11.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){var evaluated;try{evaluated=JSON.parse(value)}catch(error){void log.warn("Error occurred during parsing given json","attribute \"".concat(attributeName,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
|
|
479
479
|
this.setInternalPropertyValue(name,evaluated);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated,false,1))}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.number:case"number":{if(value===null){this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}/*
|
|
480
480
|
NOTE: You should not name this variable "number" since
|
|
481
481
|
babel gets confused caused by existing module wide
|
|
482
482
|
property type variable "number".
|
|
483
|
-
*/var numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){var _evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{binding:this});if(_evaluated.error){log.warn("Error occurred during processing given","attribute configuration \"".concat(attributeName,"\":"),_evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
483
|
+
*/var numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){var _evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{binding:this});if(_evaluated.error){void log.warn("Error occurred during processing given","attribute configuration \"".concat(attributeName,"\":"),_evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
484
484
|
this.setInternalPropertyValue(name,_evaluated.result);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(_evaluated.result,false,1))}else if(this.hasAttribute(attributeName)){this.setInternalPropertyValue(name,true);this.setExternalPropertyValue(name,true)}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}}}}/// endregion
|
|
485
485
|
/// region render
|
|
486
486
|
/**
|
|
@@ -518,7 +518,7 @@ this.setInternalPropertyValue(name,_evaluated.result);this.setExternalPropertyVa
|
|
|
518
518
|
* rendering process by their own.
|
|
519
519
|
* @returns A promise resolving when rendering has been finished. A promise
|
|
520
520
|
* may be needed for classes inheriting from this class.
|
|
521
|
-
*/},{key:"render",value:(function(){var _render=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(reason,resolveRendering){var _this14=this;var evaluated,renderTargetDomNode;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:if(reason===void 0){reason="unknown"}if(resolveRendering===void 0){resolveRendering=true}this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(!this.isRoot){_context5.n=3;break}_context5.n=1;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 1:if(!resolveRendering){_context5.n=3;break}_context5.n=2;return Promise.all(this.self.pendingRenderPromises);case 2:this.self.pendingRenderPromises=[];case 3:this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason:reason,scope:this.scope}}))){_context5.n=5;break}_context5.n=4;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 4:return _context5.a(2);case 5:evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)("`".concat(this.self.content,"`"),{scope:this.scope});if(!evaluated.error){_context5.n=7;break}log.warn("Failed to process template: ".concat(evaluated.error));this.renderState.resolve(reason);_context5.n=6;return Promise.all(this.self.pendingRenderPromises);case 6:return _context5.a(2);case 7:this.applyShadowRootIfNotExisting();/*
|
|
521
|
+
*/},{key:"render",value:(function(){var _render=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(reason,resolveRendering){var _this14=this;var evaluated,renderTargetDomNode;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:if(reason===void 0){reason="unknown"}if(resolveRendering===void 0){resolveRendering=true}this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(!this.isRoot){_context5.n=3;break}_context5.n=1;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 1:if(!resolveRendering){_context5.n=3;break}_context5.n=2;return Promise.all(this.self.pendingRenderPromises);case 2:this.self.pendingRenderPromises=[];case 3:this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason:reason,scope:this.scope}}))){_context5.n=5;break}_context5.n=4;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 4:return _context5.a(2);case 5:evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)("`".concat(this.self.content,"`"),{scope:this.scope});if(!evaluated.error){_context5.n=7;break}void log.warn("Failed to process template: ".concat(evaluated.error));this.renderState.resolve(reason);_context5.n=6;return Promise.all(this.self.pendingRenderPromises);case 6:return _context5.a(2);case 7:this.applyShadowRootIfNotExisting();/*
|
|
522
522
|
NOTE: We first render into an intermediate render target and apply
|
|
523
523
|
slot content until we finally publish everything to the document.
|
|
524
524
|
This avoids painting twice and internetexplorer bugs with an empty
|
|
@@ -737,12 +737,12 @@ domNode.determineRenderScope();if(Object.keys(this.compiledSlots).length===0)dom
|
|
|
737
737
|
*/if(key&&!Object.prototype.hasOwnProperty.call(staticProperties,"key"))staticProperties.key=key;target=domNode.constructor.content}else{staticProperties.key=key;target=domNode.tagName.toLowerCase()}/// endregion
|
|
738
738
|
/// region pre-compile dynamic properties
|
|
739
739
|
var knownScopeNames=Object.keys(scope);var compiledProperties={};var _iterator3=_createForOfIteratorHelper(domNode.getAttributeNames()),_step3;try{var _loop=function _loop(){var _value3;var attributeName=_step3.value;var _value2=domNode.getAttribute(attributeName);if(_value2===null)return 0;// continue
|
|
740
|
-
var extend=false;var name="";if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){var _compile=(0,external_clientnode_.compile)(_value2,{scope:knownScopeNames}),error=_compile.error,originalScopeNames=_compile.originalScopeNames,templateFunction=_compile.templateFunction;if(error){log.warn("Error occurred during compiling given attribute","binding \"".concat(attributeName,"\" on node:"),domNode,error);return 0;// continue
|
|
740
|
+
var extend=false;var name="";if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){var _compile=(0,external_clientnode_.compile)(_value2,{scope:knownScopeNames}),error=_compile.error,originalScopeNames=_compile.originalScopeNames,templateFunction=_compile.templateFunction;if(error){void log.warn("Error occurred during compiling given attribute","binding \"".concat(attributeName,"\" on node:"),domNode,error);return 0;// continue
|
|
741
741
|
}if(name==="attributes"||name==="properties")extend=true;else name=name.startsWith("attribute-")?name.substring("attribute-".length):name.substring("property-".length);_value2={originalScopeNames:originalScopeNames,templateFunction:templateFunction.bind(_this3)}}else if(name.startsWith("on-")){name=(0,external_clientnode_.delimitedToCamelCase)(name);if(!Object.prototype.hasOwnProperty.call(scope,"event"))knownScopeNames=[].concat(_toConsumableArray(knownScopeNames),["event"]);if(!Object.prototype.hasOwnProperty.call(scope,"parameters"))knownScopeNames=[].concat(_toConsumableArray(knownScopeNames),["parameters"]);/*
|
|
742
742
|
NOTE: We pre-compile event listener since they should
|
|
743
743
|
usually be called more than it would be re-rendered.
|
|
744
|
-
*/var _compile2=(0,external_clientnode_.compile)(_value2,{scope:knownScopeNames,execute:true}),_error=_compile2.error,_originalScopeNames=_compile2.originalScopeNames,scopeNames=_compile2.scopeNames,_templateFunction=_compile2.templateFunction;if(_error){log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,_error);return 0;// continue
|
|
745
|
-
}var eventHandler=_templateFunction.bind(_this3);_value2=function value(){for(var _len3=arguments.length,parameters=new Array(_len3),_key3=0;_key3<_len3;_key3++){parameters[_key3]=arguments[_key3]}scope.event=parameters[0];scope.parameters=parameters;try{eventHandler.apply(void 0,_toConsumableArray(_originalScopeNames.map(function(name){return scope[name]})))}catch(error){log.warn("Error occurred during processing given","event binding \"".concat(attributeName,"\" on node: "),domNode,"Given expression \"".concat(_value2,"\" could"),"not be evaluated with given scope names","\"".concat(scopeNames.join("\", \""),"\":"),(0,external_clientnode_.represent)(error))}}}else name=attributeName;var mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if((_value3=_value2)!==null&&_value3!==void 0&&_value3.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
|
|
744
|
+
*/var _compile2=(0,external_clientnode_.compile)(_value2,{scope:knownScopeNames,execute:true}),_error=_compile2.error,_originalScopeNames=_compile2.originalScopeNames,scopeNames=_compile2.scopeNames,_templateFunction=_compile2.templateFunction;if(_error){void log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,_error);return 0;// continue
|
|
745
|
+
}var eventHandler=_templateFunction.bind(_this3);_value2=function value(){for(var _len3=arguments.length,parameters=new Array(_len3),_key3=0;_key3<_len3;_key3++){parameters[_key3]=arguments[_key3]}scope.event=parameters[0];scope.parameters=parameters;try{eventHandler.apply(void 0,_toConsumableArray(_originalScopeNames.map(function(name){return scope[name]})))}catch(error){void log.warn("Error occurred during processing given","event binding \"".concat(attributeName,"\" on node: "),domNode,"Given expression \"".concat(_value2,"\" could"),"not be evaluated with given scope names","\"".concat(scopeNames.join("\", \""),"\":"),(0,external_clientnode_.represent)(error))}}}else name=attributeName;var mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if((_value3=_value2)!==null&&_value3!==void 0&&_value3.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
|
|
746
746
|
compiledProperties[extend?"":name]=_value2;else if(!isComponent)/*
|
|
747
747
|
NOTE: Properties of components are evaluated already by
|
|
748
748
|
them self and set as "internalProperties". Those
|
package/dist/compatible/Web.js
CHANGED
|
@@ -314,14 +314,14 @@ try{this.isConnected=false}catch(_unused2){// Ignore error.
|
|
|
314
314
|
* @param domNode - Node to start traversing from.
|
|
315
315
|
* @param scope - Scope to render property value again.
|
|
316
316
|
*/},{key:"applyBinding",value:function applyBinding(domNode,scope){var _this6=this;if(!domNode.getAttributeNames)return;var _iterator4=_createForOfIteratorHelper(domNode.getAttributeNames()),_step4;try{var _loop2=function _loop2(){var attributeName=_step4.value;var name;if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name){var value=domNode.getAttribute(attributeName);if(value===null)return 0;// continue
|
|
317
|
-
if(name.startsWith("attribute-")||name.startsWith("property-")){var evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:scope,binding:domNode});if(evaluated.error){log.warn("Error occurred during processing given","attribute binding \"".concat(attributeName,"\" on node:"),domNode,evaluated.error);return 0;// continue
|
|
317
|
+
if(name.startsWith("attribute-")||name.startsWith("property-")){var evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:scope,binding:domNode});if(evaluated.error){void log.warn("Error occurred during processing given","attribute binding \"".concat(attributeName,"\" on node:"),domNode,evaluated.error);return 0;// continue
|
|
318
318
|
}if(name.startsWith("attribute-"))domNode.setAttribute(name.substring("attribute-".length),evaluated.result);else/*
|
|
319
319
|
NOTE: Cast to "textContent" to have a writable
|
|
320
320
|
property here.
|
|
321
321
|
*/domNode[(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("property-".length))]=evaluated.result}else if(name.startsWith("on-")){name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("on-".length));scope=_objectSpread({log:log,event:undefined,parameters:undefined},scope);/*
|
|
322
322
|
NOTE: We pre-compile event listener since they should
|
|
323
323
|
usually be called more often than binded.
|
|
324
|
-
*/var compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scope,execute:true,binding:domNode});if(compilation.error)log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,compilation.error);else _this6.addSecureEventListener(domNode,name,function(){for(var _len=arguments.length,parameters=new Array(_len),_key=0;_key<_len;_key++){parameters[_key]=arguments[_key]}scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction.apply(compilation,_toConsumableArray(compilation.originalScopeNames.map(function(name){return scope[name]})))}catch(error){log.warn("Error occurred during processing","given event binding","\"".concat(attributeName,"\" on node:"),domNode,"Given expression \"".concat(value,"\" could"),"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+"\": ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)))}})}}},_ret;for(_iterator4.s();!(_step4=_iterator4.n()).done;){_ret=_loop2();if(_ret===0)continue}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}}/**
|
|
324
|
+
*/var compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scope,execute:true,binding:domNode});if(compilation.error)void log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,compilation.error);else _this6.addSecureEventListener(domNode,name,function(){for(var _len=arguments.length,parameters=new Array(_len),_key=0;_key<_len;_key++){parameters[_key]=arguments[_key]}scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction.apply(compilation,_toConsumableArray(compilation.originalScopeNames.map(function(name){return scope[name]})))}catch(error){void log.warn("Error occurred during processing","given event binding","\"".concat(attributeName,"\" on node:"),domNode,"Given expression \"".concat(value,"\" could"),"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+"\": ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)))}})}}},_ret;for(_iterator4.s();!(_step4=_iterator4.n()).done;){_ret=_loop2();if(_ret===0)continue}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}}/**
|
|
325
325
|
* Binds properties and event handler to given, sibling, and nested nodes.
|
|
326
326
|
* @param domNode - Node to start traversing from.
|
|
327
327
|
* @param scope - Scope to render property value again.
|
|
@@ -354,7 +354,7 @@ var currentDomNode=domNode.firstChild;while(currentDomNode){if(!options.filter||
|
|
|
354
354
|
* @param options - Evaluation options.
|
|
355
355
|
* @param scope - Scope to evaluate against.
|
|
356
356
|
* @returns Evaluated string result or null.
|
|
357
|
-
*/},{key:"evaluateCompiledDomNodeTemplate",value:function evaluateCompiledDomNodeTemplate(options,scope){var domNode=options.domNode,error=options.error,templateFunction=options.templateFunction,scopeNames=options.scopeNames;if(!(templateFunction&&scopeNames))return null;if(error){log.warn("Error occurred during compiling node content:",error);return null}var output=null;try{output=templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})))}catch(error){log.warn("Error occurred when \"".concat(this.self._name,"\" is running"),"\"".concat(String(templateFunction),"\": with bound"),"names \"".concat(scopeNames.join("\", \""),"\":"),"\"".concat(error,"\". Rendering node:"),domNode)}return output}/**
|
|
357
|
+
*/},{key:"evaluateCompiledDomNodeTemplate",value:function evaluateCompiledDomNodeTemplate(options,scope){var domNode=options.domNode,error=options.error,templateFunction=options.templateFunction,scopeNames=options.scopeNames;if(!(templateFunction&&scopeNames))return null;if(error){void log.warn("Error occurred during compiling node content:",error);return null}var output=null;try{output=templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})))}catch(error){void log.warn("Error occurred when \"".concat(this.self._name,"\" is running"),"\"".concat(String(templateFunction),"\": with bound"),"names \"".concat(scopeNames.join("\", \""),"\":"),"\"".concat(error,"\". Rendering node:"),domNode)}return output}/**
|
|
358
358
|
* Compiles and evaluates given node content and their children. Replaces
|
|
359
359
|
* each node content with their evaluated representation.
|
|
360
360
|
* @param domNode - Node to evaluate.
|
|
@@ -515,12 +515,12 @@ if(!handled&¶meters.length>0&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isO
|
|
|
515
515
|
* and registers in a property mapping object.
|
|
516
516
|
* @param attributeName - Name of given value.
|
|
517
517
|
* @param value - Value to evaluate.
|
|
518
|
-
*/)},{key:"evaluateStringOrNullAndSetAsProperty",value:function evaluateStringOrNullAndSetAsProperty(attributeName,value){var _this11=this;var preEvaluate=attributeName.startsWith("-");var effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;var name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);var alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){var type=this.self.propertyTypes[name];if(preEvaluate){if(value){var result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:_objectSpread({},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE),binding:this});if(result.error){log.warn("Failed to process pre-evaluation attribute","\"".concat(attributeName,"\": ").concat(result.error,". Will be"),"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{var booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{var error=null;var templateFunction;var scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){var _result3=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=_result3.error;templateFunction=_result3.templateFunction;if(error)log.warn("Failed to compile given handler","\"".concat(attributeName,"\": ").concat(error,"."))}this.setInternalPropertyValue(name,function(){for(var _len4=arguments.length,parameters=new Array(_len4),_key4=0;_key4<_len4;_key4++){parameters[_key4]=arguments[_key4]}if(_this11.outputEventNames.has(name))void _this11.reflectEventToProperties(name,parameters);var result=undefined;if(!error){var scope=_objectSpread({parameters:parameters},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE);for(var _i8=0,_scopeNames=scopeNames;_i8<_scopeNames.length;_i8++){var _name4=_scopeNames[_i8];scope[_name4]=parameters[0]}try{var _templateFunction;result=(_templateFunction=templateFunction)===null||_templateFunction===void 0?void 0:_templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})).concat([parameters,scope],_toConsumableArray(clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(function(name){return clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]}))))}catch(error){log.warn("Failed to evaluate function","\"".concat(attributeName,"\" with expression"),"\"".concat(value,"\" and scope"),"variables","\"".concat(scopeNames.join("\", \""),"\" set to"),"\"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters),"\":"),"".concat(error,". Set property"),"to \"undefined\".")}}if(!_this11.self.renderProperties.includes(name))_this11.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){var evaluated;try{evaluated=JSON.parse(value)}catch(error){log.warn("Error occurred during parsing given json","attribute \"".concat(attributeName,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
|
|
518
|
+
*/)},{key:"evaluateStringOrNullAndSetAsProperty",value:function evaluateStringOrNullAndSetAsProperty(attributeName,value){var _this11=this;var preEvaluate=attributeName.startsWith("-");var effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;var name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);var alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){var type=this.self.propertyTypes[name];if(preEvaluate){if(value){var result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:_objectSpread({},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE),binding:this});if(result.error){void log.warn("Failed to process pre-evaluation attribute","\"".concat(attributeName,"\": ").concat(result.error,". Will be"),"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{var booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{var error=null;var templateFunction;var scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){var _result3=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=_result3.error;templateFunction=_result3.templateFunction;if(error)void log.warn("Failed to compile given handler","\"".concat(attributeName,"\": ").concat(error,"."))}this.setInternalPropertyValue(name,function(){for(var _len4=arguments.length,parameters=new Array(_len4),_key4=0;_key4<_len4;_key4++){parameters[_key4]=arguments[_key4]}if(_this11.outputEventNames.has(name))void _this11.reflectEventToProperties(name,parameters);var result=undefined;if(!error){var scope=_objectSpread({parameters:parameters},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE);for(var _i8=0,_scopeNames=scopeNames;_i8<_scopeNames.length;_i8++){var _name4=_scopeNames[_i8];scope[_name4]=parameters[0]}try{var _templateFunction;result=(_templateFunction=templateFunction)===null||_templateFunction===void 0?void 0:_templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})).concat([parameters,scope],_toConsumableArray(clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(function(name){return clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]}))))}catch(error){void log.warn("Failed to evaluate function","\"".concat(attributeName,"\" with expression"),"\"".concat(value,"\" and scope"),"variables","\"".concat(scopeNames.join("\", \""),"\" set to"),"\"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters),"\":"),"".concat(error,". Set property"),"to \"undefined\".")}}if(!_this11.self.renderProperties.includes(name))_this11.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){var evaluated;try{evaluated=JSON.parse(value)}catch(error){void log.warn("Error occurred during parsing given json","attribute \"".concat(attributeName,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
|
|
519
519
|
this.setInternalPropertyValue(name,evaluated);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated,false,1))}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.number:case"number":{if(value===null){this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}/*
|
|
520
520
|
NOTE: You should not name this variable "number" since
|
|
521
521
|
babel gets confused caused by existing module wide
|
|
522
522
|
property type variable "number".
|
|
523
|
-
*/var numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){var _evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{binding:this});if(_evaluated.error){log.warn("Error occurred during processing given","attribute configuration \"".concat(attributeName,"\":"),_evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
523
|
+
*/var numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){var _evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{binding:this});if(_evaluated.error){void log.warn("Error occurred during processing given","attribute configuration \"".concat(attributeName,"\":"),_evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
524
524
|
this.setInternalPropertyValue(name,_evaluated.result);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(_evaluated.result,false,1))}else if(this.hasAttribute(attributeName)){this.setInternalPropertyValue(name,true);this.setExternalPropertyValue(name,true)}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}}}}/// endregion
|
|
525
525
|
/// region render
|
|
526
526
|
/**
|
|
@@ -558,7 +558,7 @@ this.setInternalPropertyValue(name,_evaluated.result);this.setExternalPropertyVa
|
|
|
558
558
|
* rendering process by their own.
|
|
559
559
|
* @returns A promise resolving when rendering has been finished. A promise
|
|
560
560
|
* may be needed for classes inheriting from this class.
|
|
561
|
-
*/},{key:"render",value:(function(){var _render=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(reason,resolveRendering){var _this14=this;var evaluated,renderTargetDomNode;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:if(reason===void 0){reason="unknown"}if(resolveRendering===void 0){resolveRendering=true}this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(!this.isRoot){_context5.n=3;break}_context5.n=1;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 1:if(!resolveRendering){_context5.n=3;break}_context5.n=2;return Promise.all(this.self.pendingRenderPromises);case 2:this.self.pendingRenderPromises=[];case 3:this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason:reason,scope:this.scope}}))){_context5.n=5;break}_context5.n=4;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 4:return _context5.a(2);case 5:evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)("`".concat(this.self.content,"`"),{scope:this.scope});if(!evaluated.error){_context5.n=7;break}log.warn("Failed to process template: ".concat(evaluated.error));this.renderState.resolve(reason);_context5.n=6;return Promise.all(this.self.pendingRenderPromises);case 6:return _context5.a(2);case 7:this.applyShadowRootIfNotExisting();/*
|
|
561
|
+
*/},{key:"render",value:(function(){var _render=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(reason,resolveRendering){var _this14=this;var evaluated,renderTargetDomNode;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:if(reason===void 0){reason="unknown"}if(resolveRendering===void 0){resolveRendering=true}this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(!this.isRoot){_context5.n=3;break}_context5.n=1;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 1:if(!resolveRendering){_context5.n=3;break}_context5.n=2;return Promise.all(this.self.pendingRenderPromises);case 2:this.self.pendingRenderPromises=[];case 3:this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason:reason,scope:this.scope}}))){_context5.n=5;break}_context5.n=4;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 4:return _context5.a(2);case 5:evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)("`".concat(this.self.content,"`"),{scope:this.scope});if(!evaluated.error){_context5.n=7;break}void log.warn("Failed to process template: ".concat(evaluated.error));this.renderState.resolve(reason);_context5.n=6;return Promise.all(this.self.pendingRenderPromises);case 6:return _context5.a(2);case 7:this.applyShadowRootIfNotExisting();/*
|
|
562
562
|
NOTE: We first render into an intermediate render target and apply
|
|
563
563
|
slot content until we finally publish everything to the document.
|
|
564
564
|
This avoids painting twice and internetexplorer bugs with an empty
|
package/dist/compatible/index.js
CHANGED
|
@@ -276,14 +276,14 @@ try{this.isConnected=false}catch(_unused2){// Ignore error.
|
|
|
276
276
|
* @param domNode - Node to start traversing from.
|
|
277
277
|
* @param scope - Scope to render property value again.
|
|
278
278
|
*/},{key:"applyBinding",value:function applyBinding(domNode,scope){var _this6=this;if(!domNode.getAttributeNames)return;var _iterator4=_createForOfIteratorHelper(domNode.getAttributeNames()),_step4;try{var _loop2=function _loop2(){var attributeName=_step4.value;var name;if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name){var value=domNode.getAttribute(attributeName);if(value===null)return 0;// continue
|
|
279
|
-
if(name.startsWith("attribute-")||name.startsWith("property-")){var evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:scope,binding:domNode});if(evaluated.error){log.warn("Error occurred during processing given","attribute binding \"".concat(attributeName,"\" on node:"),domNode,evaluated.error);return 0;// continue
|
|
279
|
+
if(name.startsWith("attribute-")||name.startsWith("property-")){var evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:scope,binding:domNode});if(evaluated.error){void log.warn("Error occurred during processing given","attribute binding \"".concat(attributeName,"\" on node:"),domNode,evaluated.error);return 0;// continue
|
|
280
280
|
}if(name.startsWith("attribute-"))domNode.setAttribute(name.substring("attribute-".length),evaluated.result);else/*
|
|
281
281
|
NOTE: Cast to "textContent" to have a writable
|
|
282
282
|
property here.
|
|
283
283
|
*/domNode[(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("property-".length))]=evaluated.result}else if(name.startsWith("on-")){name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("on-".length));scope=_objectSpread({log:log,event:undefined,parameters:undefined},scope);/*
|
|
284
284
|
NOTE: We pre-compile event listener since they should
|
|
285
285
|
usually be called more often than binded.
|
|
286
|
-
*/var compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scope,execute:true,binding:domNode});if(compilation.error)log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,compilation.error);else _this6.addSecureEventListener(domNode,name,function(){for(var _len=arguments.length,parameters=new Array(_len),_key=0;_key<_len;_key++){parameters[_key]=arguments[_key]}scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction.apply(compilation,_toConsumableArray(compilation.originalScopeNames.map(function(name){return scope[name]})))}catch(error){log.warn("Error occurred during processing","given event binding","\"".concat(attributeName,"\" on node:"),domNode,"Given expression \"".concat(value,"\" could"),"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+"\": ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)))}})}}},_ret;for(_iterator4.s();!(_step4=_iterator4.n()).done;){_ret=_loop2();if(_ret===0)continue}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}}/**
|
|
286
|
+
*/var compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scope,execute:true,binding:domNode});if(compilation.error)void log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,compilation.error);else _this6.addSecureEventListener(domNode,name,function(){for(var _len=arguments.length,parameters=new Array(_len),_key=0;_key<_len;_key++){parameters[_key]=arguments[_key]}scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction.apply(compilation,_toConsumableArray(compilation.originalScopeNames.map(function(name){return scope[name]})))}catch(error){void log.warn("Error occurred during processing","given event binding","\"".concat(attributeName,"\" on node:"),domNode,"Given expression \"".concat(value,"\" could"),"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+"\": ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)))}})}}},_ret;for(_iterator4.s();!(_step4=_iterator4.n()).done;){_ret=_loop2();if(_ret===0)continue}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}}/**
|
|
287
287
|
* Binds properties and event handler to given, sibling, and nested nodes.
|
|
288
288
|
* @param domNode - Node to start traversing from.
|
|
289
289
|
* @param scope - Scope to render property value again.
|
|
@@ -316,7 +316,7 @@ var currentDomNode=domNode.firstChild;while(currentDomNode){if(!options.filter||
|
|
|
316
316
|
* @param options - Evaluation options.
|
|
317
317
|
* @param scope - Scope to evaluate against.
|
|
318
318
|
* @returns Evaluated string result or null.
|
|
319
|
-
*/},{key:"evaluateCompiledDomNodeTemplate",value:function evaluateCompiledDomNodeTemplate(options,scope){var domNode=options.domNode,error=options.error,templateFunction=options.templateFunction,scopeNames=options.scopeNames;if(!(templateFunction&&scopeNames))return null;if(error){log.warn("Error occurred during compiling node content:",error);return null}var output=null;try{output=templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})))}catch(error){log.warn("Error occurred when \"".concat(this.self._name,"\" is running"),"\"".concat(String(templateFunction),"\": with bound"),"names \"".concat(scopeNames.join("\", \""),"\":"),"\"".concat(error,"\". Rendering node:"),domNode)}return output}/**
|
|
319
|
+
*/},{key:"evaluateCompiledDomNodeTemplate",value:function evaluateCompiledDomNodeTemplate(options,scope){var domNode=options.domNode,error=options.error,templateFunction=options.templateFunction,scopeNames=options.scopeNames;if(!(templateFunction&&scopeNames))return null;if(error){void log.warn("Error occurred during compiling node content:",error);return null}var output=null;try{output=templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})))}catch(error){void log.warn("Error occurred when \"".concat(this.self._name,"\" is running"),"\"".concat(String(templateFunction),"\": with bound"),"names \"".concat(scopeNames.join("\", \""),"\":"),"\"".concat(error,"\". Rendering node:"),domNode)}return output}/**
|
|
320
320
|
* Compiles and evaluates given node content and their children. Replaces
|
|
321
321
|
* each node content with their evaluated representation.
|
|
322
322
|
* @param domNode - Node to evaluate.
|
|
@@ -477,12 +477,12 @@ if(!handled&¶meters.length>0&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isO
|
|
|
477
477
|
* and registers in a property mapping object.
|
|
478
478
|
* @param attributeName - Name of given value.
|
|
479
479
|
* @param value - Value to evaluate.
|
|
480
|
-
*/)},{key:"evaluateStringOrNullAndSetAsProperty",value:function evaluateStringOrNullAndSetAsProperty(attributeName,value){var _this11=this;var preEvaluate=attributeName.startsWith("-");var effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;var name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);var alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){var type=this.self.propertyTypes[name];if(preEvaluate){if(value){var result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:_objectSpread({},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE),binding:this});if(result.error){log.warn("Failed to process pre-evaluation attribute","\"".concat(attributeName,"\": ").concat(result.error,". Will be"),"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{var booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{var error=null;var templateFunction;var scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){var _result3=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=_result3.error;templateFunction=_result3.templateFunction;if(error)log.warn("Failed to compile given handler","\"".concat(attributeName,"\": ").concat(error,"."))}this.setInternalPropertyValue(name,function(){for(var _len4=arguments.length,parameters=new Array(_len4),_key4=0;_key4<_len4;_key4++){parameters[_key4]=arguments[_key4]}if(_this11.outputEventNames.has(name))void _this11.reflectEventToProperties(name,parameters);var result=undefined;if(!error){var scope=_objectSpread({parameters:parameters},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE);for(var _i8=0,_scopeNames=scopeNames;_i8<_scopeNames.length;_i8++){var _name4=_scopeNames[_i8];scope[_name4]=parameters[0]}try{var _templateFunction;result=(_templateFunction=templateFunction)===null||_templateFunction===void 0?void 0:_templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})).concat([parameters,scope],_toConsumableArray(clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(function(name){return clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]}))))}catch(error){log.warn("Failed to evaluate function","\"".concat(attributeName,"\" with expression"),"\"".concat(value,"\" and scope"),"variables","\"".concat(scopeNames.join("\", \""),"\" set to"),"\"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters),"\":"),"".concat(error,". Set property"),"to \"undefined\".")}}if(!_this11.self.renderProperties.includes(name))_this11.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){var evaluated;try{evaluated=JSON.parse(value)}catch(error){log.warn("Error occurred during parsing given json","attribute \"".concat(attributeName,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
|
|
480
|
+
*/)},{key:"evaluateStringOrNullAndSetAsProperty",value:function evaluateStringOrNullAndSetAsProperty(attributeName,value){var _this11=this;var preEvaluate=attributeName.startsWith("-");var effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;var name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);var alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){var type=this.self.propertyTypes[name];if(preEvaluate){if(value){var result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:_objectSpread({},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE),binding:this});if(result.error){void log.warn("Failed to process pre-evaluation attribute","\"".concat(attributeName,"\": ").concat(result.error,". Will be"),"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{var booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{var error=null;var templateFunction;var scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){var _result3=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=_result3.error;templateFunction=_result3.templateFunction;if(error)void log.warn("Failed to compile given handler","\"".concat(attributeName,"\": ").concat(error,"."))}this.setInternalPropertyValue(name,function(){for(var _len4=arguments.length,parameters=new Array(_len4),_key4=0;_key4<_len4;_key4++){parameters[_key4]=arguments[_key4]}if(_this11.outputEventNames.has(name))void _this11.reflectEventToProperties(name,parameters);var result=undefined;if(!error){var scope=_objectSpread({parameters:parameters},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE);for(var _i8=0,_scopeNames=scopeNames;_i8<_scopeNames.length;_i8++){var _name4=_scopeNames[_i8];scope[_name4]=parameters[0]}try{var _templateFunction;result=(_templateFunction=templateFunction)===null||_templateFunction===void 0?void 0:_templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})).concat([parameters,scope],_toConsumableArray(clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(function(name){return clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]}))))}catch(error){void log.warn("Failed to evaluate function","\"".concat(attributeName,"\" with expression"),"\"".concat(value,"\" and scope"),"variables","\"".concat(scopeNames.join("\", \""),"\" set to"),"\"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters),"\":"),"".concat(error,". Set property"),"to \"undefined\".")}}if(!_this11.self.renderProperties.includes(name))_this11.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){var evaluated;try{evaluated=JSON.parse(value)}catch(error){void log.warn("Error occurred during parsing given json","attribute \"".concat(attributeName,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
|
|
481
481
|
this.setInternalPropertyValue(name,evaluated);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated,false,1))}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.number:case"number":{if(value===null){this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}/*
|
|
482
482
|
NOTE: You should not name this variable "number" since
|
|
483
483
|
babel gets confused caused by existing module wide
|
|
484
484
|
property type variable "number".
|
|
485
|
-
*/var numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){var _evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{binding:this});if(_evaluated.error){log.warn("Error occurred during processing given","attribute configuration \"".concat(attributeName,"\":"),_evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
485
|
+
*/var numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){var _evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{binding:this});if(_evaluated.error){void log.warn("Error occurred during processing given","attribute configuration \"".concat(attributeName,"\":"),_evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
486
486
|
this.setInternalPropertyValue(name,_evaluated.result);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(_evaluated.result,false,1))}else if(this.hasAttribute(attributeName)){this.setInternalPropertyValue(name,true);this.setExternalPropertyValue(name,true)}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}}}}/// endregion
|
|
487
487
|
/// region render
|
|
488
488
|
/**
|
|
@@ -520,7 +520,7 @@ this.setInternalPropertyValue(name,_evaluated.result);this.setExternalPropertyVa
|
|
|
520
520
|
* rendering process by their own.
|
|
521
521
|
* @returns A promise resolving when rendering has been finished. A promise
|
|
522
522
|
* may be needed for classes inheriting from this class.
|
|
523
|
-
*/},{key:"render",value:(function(){var _render=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(reason,resolveRendering){var _this14=this;var evaluated,renderTargetDomNode;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:if(reason===void 0){reason="unknown"}if(resolveRendering===void 0){resolveRendering=true}this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(!this.isRoot){_context5.n=3;break}_context5.n=1;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 1:if(!resolveRendering){_context5.n=3;break}_context5.n=2;return Promise.all(this.self.pendingRenderPromises);case 2:this.self.pendingRenderPromises=[];case 3:this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason:reason,scope:this.scope}}))){_context5.n=5;break}_context5.n=4;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 4:return _context5.a(2);case 5:evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)("`".concat(this.self.content,"`"),{scope:this.scope});if(!evaluated.error){_context5.n=7;break}log.warn("Failed to process template: ".concat(evaluated.error));this.renderState.resolve(reason);_context5.n=6;return Promise.all(this.self.pendingRenderPromises);case 6:return _context5.a(2);case 7:this.applyShadowRootIfNotExisting();/*
|
|
523
|
+
*/},{key:"render",value:(function(){var _render=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(reason,resolveRendering){var _this14=this;var evaluated,renderTargetDomNode;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:if(reason===void 0){reason="unknown"}if(resolveRendering===void 0){resolveRendering=true}this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(!this.isRoot){_context5.n=3;break}_context5.n=1;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 1:if(!resolveRendering){_context5.n=3;break}_context5.n=2;return Promise.all(this.self.pendingRenderPromises);case 2:this.self.pendingRenderPromises=[];case 3:this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason:reason,scope:this.scope}}))){_context5.n=5;break}_context5.n=4;return this.resolveRenderingPromiseIfSet(reason,resolveRendering);case 4:return _context5.a(2);case 5:evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)("`".concat(this.self.content,"`"),{scope:this.scope});if(!evaluated.error){_context5.n=7;break}void log.warn("Failed to process template: ".concat(evaluated.error));this.renderState.resolve(reason);_context5.n=6;return Promise.all(this.self.pendingRenderPromises);case 6:return _context5.a(2);case 7:this.applyShadowRootIfNotExisting();/*
|
|
524
524
|
NOTE: We first render into an intermediate render target and apply
|
|
525
525
|
slot content until we finally publish everything to the document.
|
|
526
526
|
This avoids painting twice and internetexplorer bugs with an empty
|
|
@@ -709,12 +709,12 @@ domNode.determineRenderScope();if(Object.keys(this.compiledSlots).length===0)dom
|
|
|
709
709
|
*/if(key&&!Object.prototype.hasOwnProperty.call(staticProperties,"key"))staticProperties.key=key;target=domNode.constructor.content}else{staticProperties.key=key;target=domNode.tagName.toLowerCase()}/// endregion
|
|
710
710
|
/// region pre-compile dynamic properties
|
|
711
711
|
var knownScopeNames=Object.keys(scope);var compiledProperties={};var _iterator3=_createForOfIteratorHelper(domNode.getAttributeNames()),_step3;try{var _loop=function _loop(){var _value3;var attributeName=_step3.value;var _value2=domNode.getAttribute(attributeName);if(_value2===null)return 0;// continue
|
|
712
|
-
var extend=false;var name="";if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){var _compile=(0,external_clientnode_.compile)(_value2,{scope:knownScopeNames}),error=_compile.error,originalScopeNames=_compile.originalScopeNames,templateFunction=_compile.templateFunction;if(error){log.warn("Error occurred during compiling given attribute","binding \"".concat(attributeName,"\" on node:"),domNode,error);return 0;// continue
|
|
712
|
+
var extend=false;var name="";if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){var _compile=(0,external_clientnode_.compile)(_value2,{scope:knownScopeNames}),error=_compile.error,originalScopeNames=_compile.originalScopeNames,templateFunction=_compile.templateFunction;if(error){void log.warn("Error occurred during compiling given attribute","binding \"".concat(attributeName,"\" on node:"),domNode,error);return 0;// continue
|
|
713
713
|
}if(name==="attributes"||name==="properties")extend=true;else name=name.startsWith("attribute-")?name.substring("attribute-".length):name.substring("property-".length);_value2={originalScopeNames:originalScopeNames,templateFunction:templateFunction.bind(_this3)}}else if(name.startsWith("on-")){name=(0,external_clientnode_.delimitedToCamelCase)(name);if(!Object.prototype.hasOwnProperty.call(scope,"event"))knownScopeNames=[].concat(_toConsumableArray(knownScopeNames),["event"]);if(!Object.prototype.hasOwnProperty.call(scope,"parameters"))knownScopeNames=[].concat(_toConsumableArray(knownScopeNames),["parameters"]);/*
|
|
714
714
|
NOTE: We pre-compile event listener since they should
|
|
715
715
|
usually be called more than it would be re-rendered.
|
|
716
|
-
*/var _compile2=(0,external_clientnode_.compile)(_value2,{scope:knownScopeNames,execute:true}),_error=_compile2.error,_originalScopeNames=_compile2.originalScopeNames,scopeNames=_compile2.scopeNames,_templateFunction=_compile2.templateFunction;if(_error){log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,_error);return 0;// continue
|
|
717
|
-
}var eventHandler=_templateFunction.bind(_this3);_value2=function value(){for(var _len3=arguments.length,parameters=new Array(_len3),_key3=0;_key3<_len3;_key3++){parameters[_key3]=arguments[_key3]}scope.event=parameters[0];scope.parameters=parameters;try{eventHandler.apply(void 0,_toConsumableArray(_originalScopeNames.map(function(name){return scope[name]})))}catch(error){log.warn("Error occurred during processing given","event binding \"".concat(attributeName,"\" on node: "),domNode,"Given expression \"".concat(_value2,"\" could"),"not be evaluated with given scope names","\"".concat(scopeNames.join("\", \""),"\":"),(0,external_clientnode_.represent)(error))}}}else name=attributeName;var mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if((_value3=_value2)!==null&&_value3!==void 0&&_value3.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
|
|
716
|
+
*/var _compile2=(0,external_clientnode_.compile)(_value2,{scope:knownScopeNames,execute:true}),_error=_compile2.error,_originalScopeNames=_compile2.originalScopeNames,scopeNames=_compile2.scopeNames,_templateFunction=_compile2.templateFunction;if(_error){void log.warn("Error occurred during compiling given event","binding \"".concat(attributeName,"\" on node:"),domNode,_error);return 0;// continue
|
|
717
|
+
}var eventHandler=_templateFunction.bind(_this3);_value2=function value(){for(var _len3=arguments.length,parameters=new Array(_len3),_key3=0;_key3<_len3;_key3++){parameters[_key3]=arguments[_key3]}scope.event=parameters[0];scope.parameters=parameters;try{eventHandler.apply(void 0,_toConsumableArray(_originalScopeNames.map(function(name){return scope[name]})))}catch(error){void log.warn("Error occurred during processing given","event binding \"".concat(attributeName,"\" on node: "),domNode,"Given expression \"".concat(_value2,"\" could"),"not be evaluated with given scope names","\"".concat(scopeNames.join("\", \""),"\":"),(0,external_clientnode_.represent)(error))}}}else name=attributeName;var mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if((_value3=_value2)!==null&&_value3!==void 0&&_value3.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
|
|
718
718
|
compiledProperties[extend?"":name]=_value2;else if(!isComponent)/*
|
|
719
719
|
NOTE: Properties of components are evaluated already by
|
|
720
720
|
them self and set as "internalProperties". Those
|
package/dist/index.js
CHANGED
|
@@ -279,13 +279,13 @@ try{this.isConnected=false}catch{// Ignore error.
|
|
|
279
279
|
* Binds properties and event handler to the given dom node.
|
|
280
280
|
* @param domNode - Node to start traversing from.
|
|
281
281
|
* @param scope - Scope to render property value again.
|
|
282
|
-
*/applyBinding(domNode,scope){if(!domNode.getAttributeNames)return;for(const attributeName of domNode.getAttributeNames()){let name;if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name){const value=domNode.getAttribute(attributeName);if(value===null)continue;if(name.startsWith("attribute-")||name.startsWith("property-")){const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope,binding:domNode});if(evaluated.error){log.warn("Error occurred during processing given",`attribute binding "${attributeName}" on node:`,domNode,evaluated.error);continue}if(name.startsWith("attribute-"))domNode.setAttribute(name.substring("attribute-".length),evaluated.result);else/*
|
|
282
|
+
*/applyBinding(domNode,scope){if(!domNode.getAttributeNames)return;for(const attributeName of domNode.getAttributeNames()){let name;if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name){const value=domNode.getAttribute(attributeName);if(value===null)continue;if(name.startsWith("attribute-")||name.startsWith("property-")){const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope,binding:domNode});if(evaluated.error){void log.warn("Error occurred during processing given",`attribute binding "${attributeName}" on node:`,domNode,evaluated.error);continue}if(name.startsWith("attribute-"))domNode.setAttribute(name.substring("attribute-".length),evaluated.result);else/*
|
|
283
283
|
NOTE: Cast to "textContent" to have a writable
|
|
284
284
|
property here.
|
|
285
285
|
*/domNode[(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("property-".length))]=evaluated.result}else if(name.startsWith("on-")){name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("on-".length));scope={log,event:undefined,parameters:undefined,...scope};/*
|
|
286
286
|
NOTE: We pre-compile event listener since they should
|
|
287
287
|
usually be called more often than binded.
|
|
288
|
-
*/const compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope,execute:true,binding:domNode});if(compilation.error)log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,compilation.error);else this.addSecureEventListener(domNode,name,(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction(/*
|
|
288
|
+
*/const compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope,execute:true,binding:domNode});if(compilation.error)void log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,compilation.error);else this.addSecureEventListener(domNode,name,(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction(/*
|
|
289
289
|
NOTE: We want to be sure to have
|
|
290
290
|
the same ordering as we have for
|
|
291
291
|
the scope names and to call
|
|
@@ -293,7 +293,7 @@ try{this.isConnected=false}catch{// Ignore error.
|
|
|
293
293
|
retrieving values. So simple using
|
|
294
294
|
"...Object.values(scope)" is not
|
|
295
295
|
appreciate here.
|
|
296
|
-
*/...compilation.originalScopeNames.map(name=>scope[name]))}catch(error){log.warn("Error occurred during processing","given event binding",`"${attributeName}" on node:`,domNode,`Given expression "${value}" could`,"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+`": ${(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)}`)}})}}}}/**
|
|
296
|
+
*/...compilation.originalScopeNames.map(name=>scope[name]))}catch(error){void log.warn("Error occurred during processing","given event binding",`"${attributeName}" on node:`,domNode,`Given expression "${value}" could`,"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+`": ${(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)}`)}})}}}}/**
|
|
297
297
|
* Binds properties and event handler to given, sibling, and nested nodes.
|
|
298
298
|
* @param domNode - Node to start traversing from.
|
|
299
299
|
* @param scope - Scope to render property value again.
|
|
@@ -326,7 +326,7 @@ let currentDomNode=domNode.firstChild;while(currentDomNode){if(!options.filter||
|
|
|
326
326
|
* @param options - Evaluation options.
|
|
327
327
|
* @param scope - Scope to evaluate against.
|
|
328
328
|
* @returns Evaluated string result or null.
|
|
329
|
-
*/evaluateCompiledDomNodeTemplate(options,scope){const{domNode,error,templateFunction,scopeNames}=options;if(!(templateFunction&&scopeNames))return null;if(error){log.warn("Error occurred during compiling node content:",error);return null}let output=null;try{output=templateFunction(...scopeNames.map(name=>scope[name]))}catch(error){log.warn(`Error occurred when "${this.self._name}" is running`,`"${String(templateFunction)}": with bound`,`names "${scopeNames.join("\", \"")}":`,`"${error}". Rendering node:`,domNode)}return output}/**
|
|
329
|
+
*/evaluateCompiledDomNodeTemplate(options,scope){const{domNode,error,templateFunction,scopeNames}=options;if(!(templateFunction&&scopeNames))return null;if(error){void log.warn("Error occurred during compiling node content:",error);return null}let output=null;try{output=templateFunction(...scopeNames.map(name=>scope[name]))}catch(error){void log.warn(`Error occurred when "${this.self._name}" is running`,`"${String(templateFunction)}": with bound`,`names "${scopeNames.join("\", \"")}":`,`"${error}". Rendering node:`,domNode)}return output}/**
|
|
330
330
|
* Compiles and evaluates given node content and their children. Replaces
|
|
331
331
|
* each node content with their evaluated representation.
|
|
332
332
|
* @param domNode - Node to evaluate.
|
|
@@ -492,12 +492,12 @@ if(!handled&¶meters.length>0&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isO
|
|
|
492
492
|
* and registers in a property mapping object.
|
|
493
493
|
* @param attributeName - Name of given value.
|
|
494
494
|
* @param value - Value to evaluate.
|
|
495
|
-
*/evaluateStringOrNullAndSetAsProperty(attributeName,value){const preEvaluate=attributeName.startsWith("-");const effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;let name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);const alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){const type=this.self.propertyTypes[name];if(preEvaluate){if(value){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE},binding:this});if(result.error){log.warn(`Failed to process pre-evaluation attribute`,`"${attributeName}": ${result.error}. Will be`,"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{const booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{let error=null;let templateFunction;const scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=result.error;templateFunction=result.templateFunction;if(error)log.warn("Failed to compile given handler",`"${attributeName}": ${error}.`)}this.setInternalPropertyValue(name,(...parameters)=>{if(this.outputEventNames.has(name))void this.reflectEventToProperties(name,parameters);let result=undefined;if(!error){const scope={parameters,...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE};for(const name of scopeNames)scope[name]=parameters[0];try{result=templateFunction?.(...scopeNames.map(name=>scope[name]),parameters,scope,...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(name=>clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]))}catch(error){log.warn("Failed to evaluate function",`"${attributeName}" with expression`,`"${value}" and scope`,"variables",`"${scopeNames.join("\", \"")}" set to`,`"${(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters)}":`,`${error}. Set property`,`to "undefined".`)}}if(!this.self.renderProperties.includes(name))this.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){let evaluated;try{evaluated=JSON.parse(value)}catch(error){log.warn("Error occurred during parsing given json",`attribute "${attributeName}":`,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
|
|
495
|
+
*/evaluateStringOrNullAndSetAsProperty(attributeName,value){const preEvaluate=attributeName.startsWith("-");const effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;let name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);const alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){const type=this.self.propertyTypes[name];if(preEvaluate){if(value){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{scope:{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE},binding:this});if(result.error){void log.warn(`Failed to process pre-evaluation attribute`,`"${attributeName}": ${result.error}. Will be`,"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{const booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{let error=null;let templateFunction;const scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=result.error;templateFunction=result.templateFunction;if(error)void log.warn("Failed to compile given handler",`"${attributeName}": ${error}.`)}this.setInternalPropertyValue(name,(...parameters)=>{if(this.outputEventNames.has(name))void this.reflectEventToProperties(name,parameters);let result=undefined;if(!error){const scope={parameters,...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE};for(const name of scopeNames)scope[name]=parameters[0];try{result=templateFunction?.(...scopeNames.map(name=>scope[name]),parameters,scope,...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(name=>clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]))}catch(error){void log.warn("Failed to evaluate function",`"${attributeName}" with expression`,`"${value}" and scope`,"variables",`"${scopeNames.join("\", \"")}" set to`,`"${(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters)}":`,`${error}. Set property`,`to "undefined".`)}}if(!this.self.renderProperties.includes(name))this.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){let evaluated;try{evaluated=JSON.parse(value)}catch(error){void log.warn("Error occurred during parsing given json",`attribute "${attributeName}":`,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
|
|
496
496
|
this.setInternalPropertyValue(name,evaluated);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated,false,1))}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.number:case"number":{if(value===null){this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}/*
|
|
497
497
|
NOTE: You should not name this variable "number" since
|
|
498
498
|
babel gets confused caused by existing module wide
|
|
499
499
|
property type variable "number".
|
|
500
|
-
*/let numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{binding:this});if(evaluated.error){log.warn("Error occurred during processing given",`attribute configuration "${attributeName}":`,evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
500
|
+
*/let numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{binding:this});if(evaluated.error){void log.warn("Error occurred during processing given",`attribute configuration "${attributeName}":`,evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
501
501
|
this.setInternalPropertyValue(name,evaluated.result);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated.result,false,1))}else if(this.hasAttribute(attributeName)){this.setInternalPropertyValue(name,true);this.setExternalPropertyValue(name,true)}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}}}}/// endregion
|
|
502
502
|
/// region render
|
|
503
503
|
/**
|
|
@@ -535,7 +535,7 @@ this.setInternalPropertyValue(name,evaluated.result);this.setExternalPropertyVal
|
|
|
535
535
|
* rendering process by their own.
|
|
536
536
|
* @returns A promise resolving when rendering has been finished. A promise
|
|
537
537
|
* may be needed for classes inheriting from this class.
|
|
538
|
-
*/async render(reason="unknown",resolveRendering=true){this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(this.isRoot){await this.resolveRenderingPromiseIfSet(reason,resolveRendering);if(resolveRendering){await Promise.all(this.self.pendingRenderPromises);this.self.pendingRenderPromises=[]}}this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(!(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason,scope:this.scope}})))){await this.resolveRenderingPromiseIfSet(reason,resolveRendering);return}const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(`\`${this.self.content}\``,{scope:this.scope});if(evaluated.error){log.warn(`Failed to process template: ${evaluated.error}`);this.renderState.resolve(reason);await Promise.all(this.self.pendingRenderPromises);return}this.applyShadowRootIfNotExisting();/*
|
|
538
|
+
*/async render(reason="unknown",resolveRendering=true){this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(this.isRoot){await this.resolveRenderingPromiseIfSet(reason,resolveRendering);if(resolveRendering){await Promise.all(this.self.pendingRenderPromises);this.self.pendingRenderPromises=[]}}this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(!(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason,scope:this.scope}})))){await this.resolveRenderingPromiseIfSet(reason,resolveRendering);return}const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(`\`${this.self.content}\``,{scope:this.scope});if(evaluated.error){void log.warn(`Failed to process template: ${evaluated.error}`);this.renderState.resolve(reason);await Promise.all(this.self.pendingRenderPromises);return}this.applyShadowRootIfNotExisting();/*
|
|
539
539
|
NOTE: We first render into an intermediate render target and apply
|
|
540
540
|
slot content until we finally publish everything to the document.
|
|
541
541
|
This avoids painting twice and internetexplorer bugs with an empty
|
|
@@ -718,17 +718,17 @@ domNode.determineRenderScope();if(Object.keys(this.compiledSlots).length===0)dom
|
|
|
718
718
|
actually rendering the nested component.
|
|
719
719
|
*/if(key&&!Object.prototype.hasOwnProperty.call(staticProperties,"key"))staticProperties.key=key;target=domNode.constructor.content}else{staticProperties.key=key;target=domNode.tagName.toLowerCase()}/// endregion
|
|
720
720
|
/// region pre-compile dynamic properties
|
|
721
|
-
let knownScopeNames=Object.keys(scope);const compiledProperties={};for(const attributeName of domNode.getAttributeNames()){let value=domNode.getAttribute(attributeName);if(value===null)continue;let extend=false;let name="";if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){const{error,originalScopeNames,templateFunction}=(0,external_clientnode_.compile)(value,{scope:knownScopeNames});if(error){log.warn("Error occurred during compiling given attribute",`binding "${attributeName}" on node:`,domNode,error);continue}if(name==="attributes"||name==="properties")extend=true;else name=name.startsWith("attribute-")?name.substring("attribute-".length):name.substring("property-".length);value={originalScopeNames,templateFunction:templateFunction.bind(this)}}else if(name.startsWith("on-")){name=(0,external_clientnode_.delimitedToCamelCase)(name);if(!Object.prototype.hasOwnProperty.call(scope,"event"))knownScopeNames=[...knownScopeNames,"event"];if(!Object.prototype.hasOwnProperty.call(scope,"parameters"))knownScopeNames=[...knownScopeNames,"parameters"];/*
|
|
721
|
+
let knownScopeNames=Object.keys(scope);const compiledProperties={};for(const attributeName of domNode.getAttributeNames()){let value=domNode.getAttribute(attributeName);if(value===null)continue;let extend=false;let name="";if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){const{error,originalScopeNames,templateFunction}=(0,external_clientnode_.compile)(value,{scope:knownScopeNames});if(error){void log.warn("Error occurred during compiling given attribute",`binding "${attributeName}" on node:`,domNode,error);continue}if(name==="attributes"||name==="properties")extend=true;else name=name.startsWith("attribute-")?name.substring("attribute-".length):name.substring("property-".length);value={originalScopeNames,templateFunction:templateFunction.bind(this)}}else if(name.startsWith("on-")){name=(0,external_clientnode_.delimitedToCamelCase)(name);if(!Object.prototype.hasOwnProperty.call(scope,"event"))knownScopeNames=[...knownScopeNames,"event"];if(!Object.prototype.hasOwnProperty.call(scope,"parameters"))knownScopeNames=[...knownScopeNames,"parameters"];/*
|
|
722
722
|
NOTE: We pre-compile event listener since they should
|
|
723
723
|
usually be called more than it would be re-rendered.
|
|
724
|
-
*/const{error,originalScopeNames,scopeNames,templateFunction}=(0,external_clientnode_.compile)(value,{scope:knownScopeNames,execute:true});if(error){log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,error);continue}const eventHandler=templateFunction.bind(this);value=(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{eventHandler(/*
|
|
724
|
+
*/const{error,originalScopeNames,scopeNames,templateFunction}=(0,external_clientnode_.compile)(value,{scope:knownScopeNames,execute:true});if(error){void log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,error);continue}const eventHandler=templateFunction.bind(this);value=(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{eventHandler(/*
|
|
725
725
|
NOTE: We want to be ensured to have the same
|
|
726
726
|
ordering as we have for the scope names and to
|
|
727
727
|
call internal registered getter by retrieving
|
|
728
728
|
values. So simple using
|
|
729
729
|
"...Object.values(scope)" is not appreciate
|
|
730
730
|
here.
|
|
731
|
-
*/...originalScopeNames.map(name=>scope[name]))}catch(error){log.warn("Error occurred during processing given",`event binding "${attributeName}" on node: `,domNode,`Given expression "${value}" could`,"not be evaluated with given scope names",`"${scopeNames.join("\", \"")}":`,(0,external_clientnode_.represent)(error))}}}else name=attributeName;const mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if(value?.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
|
|
731
|
+
*/...originalScopeNames.map(name=>scope[name]))}catch(error){void log.warn("Error occurred during processing given",`event binding "${attributeName}" on node: `,domNode,`Given expression "${value}" could`,"not be evaluated with given scope names",`"${scopeNames.join("\", \"")}":`,(0,external_clientnode_.represent)(error))}}}else name=attributeName;const mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if(value?.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
|
|
732
732
|
compiledProperties[extend?"":name]=value;else if(!isComponent)/*
|
|
733
733
|
NOTE: Properties of components are evaluated already by
|
|
734
734
|
them self and set as "internalProperties". Those
|
|
@@ -886,7 +886,7 @@ let propertiesToReflectAsAttributes=configuration.propertiesToReflectAsAttribute
|
|
|
886
886
|
*/class ConcreteComponent extends ReactWeb{constructor(...args){super(...args);_defineProperty(this,"self",ConcreteComponent);_defineProperty(this,"internalProperties",configuration.internalProperties?{...configuration.internalProperties}:component.internalProperties?{...component.internalProperties}:{});_defineProperty(this,"unmountOnDisconnect",configuration.unmountOnDisconnect??true)}}_defineProperty(ConcreteComponent,"attachWebComponentAdapterIfNotExists",typeof configuration.attachWebComponentAdapterIfNotExists==="boolean"?configuration.attachWebComponentAdapterIfNotExists:true);_defineProperty(ConcreteComponent,"content",component);_defineProperty(ConcreteComponent,"observedAttributes",ReactWeb.observedAttributes.concat(attributeNames)// NOTE: Respect pre-evaluation indicator attributes.
|
|
887
887
|
.concat(attributeNames.map(name=>`-${name}`)));_defineProperty(ConcreteComponent,"controllableProperties",component.controllableProperties||configuration.controllableProperties||[]);_defineProperty(ConcreteComponent,"eventToPropertyMapping",configuration.eventToPropertyMapping===null?configuration.eventToPropertyMapping:configuration.eventToPropertyMapping?{...configuration.eventToPropertyMapping}:component.eventToPropertyMapping===null?component.eventToPropertyMapping:component.eventToPropertyMapping?{...component.eventToPropertyMapping}:{});_defineProperty(ConcreteComponent,"propertyAliases",{...ReactWeb.propertyAliases,...propertyAliases});_defineProperty(ConcreteComponent,"propertiesToReflectAsAttributes",propertiesToReflectAsAttributes);_defineProperty(ConcreteComponent,"propertyTypes",{...ReactWeb.propertyTypes,...propertyTypes});_defineProperty(ConcreteComponent,"renderProperties",configuration.renderProperties??component.renderProperties??ReactWeb.renderProperties);_defineProperty(ConcreteComponent,"_name",name);const webComponentAPI={component:ConcreteComponent,register:(tagName=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(name))=>{customElements.define(tagName,ConcreteComponent)}};return webComponentAPI};/* harmony default export */ const src = (wrapAsWebComponent);
|
|
888
888
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
889
|
-
/* harmony export */ "Ay", 0,
|
|
889
|
+
/* harmony export */ "Ay", 0, src,
|
|
890
890
|
/* harmony export */ "MZ", 0, /* binding */ property,
|
|
891
891
|
/* harmony export */ "Nc", 0, /* binding */ Web,
|
|
892
892
|
/* harmony export */ "YF", 0, /* binding */ wrapAsWebComponent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-component-wrapper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.615",
|
|
4
4
|
"description": "Generic web-component base class and framework specific wrapper.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
],
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"scripts": {
|
|
56
|
-
"build": "yarn build:types
|
|
56
|
+
"build": "yarn build:types && yarn build:plain && yarn build:compatible && yarn build:bundle && yarn build:bundle:compatible",
|
|
57
57
|
"build:bundle": "weboptimizer build '{__reference__: \"target:bundle\"}'",
|
|
58
58
|
"build:bundle:compatible": "weboptimizer build '{__reference__: [\"target:bundle\", \"target:compatible\", \"target:bundle:compatible\"]}'",
|
|
59
59
|
"build:compatible": "weboptimizer build '{__reference__: \"target:compatible\"}'",
|
|
60
60
|
"build:plain": "weboptimizer build",
|
|
61
61
|
"build:types": "weboptimizer build:types",
|
|
62
|
-
"check": "yarn check:types
|
|
62
|
+
"check": "yarn check:types && yarn lint",
|
|
63
63
|
"check:types": "weboptimizer check:types",
|
|
64
64
|
"clear": "weboptimizer clear",
|
|
65
65
|
"document": "weboptimizer document",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"prepare": "yarn build",
|
|
68
68
|
"serve": "weboptimizer serve",
|
|
69
69
|
"start": "yarn serve",
|
|
70
|
-
"test": "yarn clear
|
|
71
|
-
"test:browser": "yarn clear
|
|
72
|
-
"test:coverage": "yarn clear
|
|
73
|
-
"test:coverage:report": "yarn clear
|
|
70
|
+
"test": "yarn clear && weboptimizer test",
|
|
71
|
+
"test:browser": "yarn clear && weboptimizer test:browser",
|
|
72
|
+
"test:coverage": "yarn clear && weboptimizer test:coverage",
|
|
73
|
+
"test:coverage:report": "yarn clear && weboptimizer test:coverage:report",
|
|
74
74
|
"update:documentation": "web-documentation",
|
|
75
75
|
"watch": "weboptimizer build --watch"
|
|
76
76
|
},
|
|
@@ -81,25 +81,25 @@
|
|
|
81
81
|
"@types/ejs": "^3.1.5",
|
|
82
82
|
"@types/html-minifier": "^4.0.6",
|
|
83
83
|
"@types/jsdom": "^30.0.0",
|
|
84
|
-
"@types/node": "^26.
|
|
84
|
+
"@types/node": "^26.6.0",
|
|
85
85
|
"@types/react": "^19.3.0",
|
|
86
86
|
"@types/react-dom": "^19.3.0",
|
|
87
87
|
"@types/webpack-env": "^1.18.8",
|
|
88
88
|
"@typescript-eslint/eslint-plugin": "^8.70.0",
|
|
89
89
|
"@typescript-eslint/parser": "^8.70.0",
|
|
90
90
|
"@webcomponents/webcomponentsjs": "^2.8.0",
|
|
91
|
-
"clientnode": "^4.0.
|
|
91
|
+
"clientnode": "^4.0.1521",
|
|
92
92
|
"eslint": "^10.10.0",
|
|
93
93
|
"eslint-config-google": "^0.14.0",
|
|
94
|
-
"eslint-plugin-jsdoc": "^64.
|
|
94
|
+
"eslint-plugin-jsdoc": "^64.5.0",
|
|
95
95
|
"jest": "30.5.1",
|
|
96
96
|
"jsdoc": "^4.0.5",
|
|
97
97
|
"prop-types": "^15.8.1",
|
|
98
98
|
"react": "^19.3.0",
|
|
99
99
|
"react-dom": "^19.3.0",
|
|
100
100
|
"typescript-eslint": "^8.70.0",
|
|
101
|
-
"web-documentation": "^1.0.
|
|
102
|
-
"weboptimizer": "^4.0.
|
|
101
|
+
"web-documentation": "^1.0.60",
|
|
102
|
+
"weboptimizer": "^4.0.85",
|
|
103
103
|
"webpack-dev-server": "^6.0.0"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|