mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Fix: eventcatcher widget - variables can be undefined (#6668)
* Fix: eventcatcher widget - variables can be undefined * Fix: selectedNode can be an svg where offsetLeft ... are undefined * Make check for offsetLeft short * remove second collectDOMNodeVariables
This commit is contained in:
parent
9b9e443c73
commit
4b8594c4a8
@ -292,14 +292,17 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
|
||||
$tw.utils.each(selectedNode.attributes,function(attribute) {
|
||||
variables["dom-" + attribute.name] = attribute.value.toString();
|
||||
});
|
||||
// Add a variable with a popup coordinate string for the selected node
|
||||
variables["tv-popup-coords"] = "(" + selectedNode.offsetLeft + "," + selectedNode.offsetTop +"," + selectedNode.offsetWidth + "," + selectedNode.offsetHeight + ")";
|
||||
|
||||
if(selectedNode.offsetLeft) {
|
||||
// Add a variable with a popup coordinate string for the selected node
|
||||
variables["tv-popup-coords"] = "(" + selectedNode.offsetLeft + "," + selectedNode.offsetTop +"," + selectedNode.offsetWidth + "," + selectedNode.offsetHeight + ")";
|
||||
|
||||
// Add variables for offset of selected node
|
||||
variables["tv-selectednode-posx"] = selectedNode.offsetLeft.toString();
|
||||
variables["tv-selectednode-posy"] = selectedNode.offsetTop.toString();
|
||||
variables["tv-selectednode-width"] = selectedNode.offsetWidth.toString();
|
||||
variables["tv-selectednode-height"] = selectedNode.offsetHeight.toString();
|
||||
// Add variables for offset of selected node
|
||||
variables["tv-selectednode-posx"] = selectedNode.offsetLeft.toString();
|
||||
variables["tv-selectednode-posy"] = selectedNode.offsetTop.toString();
|
||||
variables["tv-selectednode-width"] = selectedNode.offsetWidth.toString();
|
||||
variables["tv-selectednode-height"] = selectedNode.offsetHeight.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(event && event.clientX && event.clientY) {
|
||||
|
@ -52,7 +52,7 @@ EventWidget.prototype.render = function(parent,nextSibling) {
|
||||
selectedNode = event.target,
|
||||
selectedNodeRect,
|
||||
catcherNodeRect,
|
||||
variables;
|
||||
variables = {};
|
||||
// Firefox can fire dragover and dragenter events on text nodes instead of their parents
|
||||
if(selectedNode.nodeType === 3) {
|
||||
selectedNode = selectedNode.parentNode;
|
||||
|
Loading…
Reference in New Issue
Block a user