mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 17:40:29 +00:00
Slight optimisation to user defined widgets
This commit is contained in:
parent
fddaa9fdb1
commit
1aba8a1f65
@ -501,13 +501,15 @@ Widget.prototype.makeChildWidget = function(parseTreeNode,options) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
// Check whether this node type is defined by a custom widget definition
|
// Check whether this node type is defined by a custom widget definition
|
||||||
var variableDefinitionName = "$" + parseTreeNode.type,
|
var variableDefinitionName = "$" + parseTreeNode.type;
|
||||||
variableInfo = this.getVariableInfo(variableDefinitionName,{allowSelfAssigned: true}),
|
if(this.variables[variableDefinitionName]) {
|
||||||
isOverrideable = function() {
|
var isOverrideable = function() {
|
||||||
// Widget is overrideable if it has a double dollar user defined name, or if it is an existing JS widget and we're not in safe mode
|
// Widget is overrideable if it has a double dollar user defined name, or if it is an existing JS widget and we're not in safe mode
|
||||||
return parseTreeNode.type.charAt(0) === "$" || (!!self.widgetClasses[parseTreeNode.type] && !$tw.safeMode);
|
return parseTreeNode.type.charAt(0) === "$" || (!!self.widgetClasses[parseTreeNode.type] && !$tw.safeMode);
|
||||||
};
|
};
|
||||||
if(!parseTreeNode.isNotRemappable && isOverrideable() && variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.value && variableInfo.srcVariable.isWidgetDefinition) {
|
if(!parseTreeNode.isNotRemappable && isOverrideable()) {
|
||||||
|
var variableInfo = this.getVariableInfo(variableDefinitionName,{allowSelfAssigned: true});
|
||||||
|
if(variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.value && variableInfo.srcVariable.isWidgetDefinition) {
|
||||||
var newParseTreeNode = {
|
var newParseTreeNode = {
|
||||||
type: "transclude",
|
type: "transclude",
|
||||||
children: parseTreeNode.children,
|
children: parseTreeNode.children,
|
||||||
@ -521,6 +523,8 @@ Widget.prototype.makeChildWidget = function(parseTreeNode,options) {
|
|||||||
});
|
});
|
||||||
parseTreeNode = newParseTreeNode;
|
parseTreeNode = newParseTreeNode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Get the widget class for this node type
|
// Get the widget class for this node type
|
||||||
var WidgetClass = this.widgetClasses[parseTreeNode.type];
|
var WidgetClass = this.widgetClasses[parseTreeNode.type];
|
||||||
if(!WidgetClass) {
|
if(!WidgetClass) {
|
||||||
|
Loading…
Reference in New Issue
Block a user