1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-29 12:59:56 +00:00

Fix detection of DOM properties

Alternate fix for #7714
This commit is contained in:
Jeremy Ruston 2023-11-21 11:54:37 +00:00
parent 06b1cc4bca
commit de6b866f22

View File

@ -313,7 +313,7 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
variables["dom-" + attribute.name] = attribute.value.toString(); variables["dom-" + attribute.name] = attribute.value.toString();
}); });
if(selectedNode.offsetLeft) { if("offsetLeft" in selectedNode) {
// Add variables with a (relative and absolute) popup coordinate string for the selected node // Add variables with a (relative and absolute) popup coordinate string for the selected node
var nodeRect = { var nodeRect = {
left: selectedNode.offsetLeft, left: selectedNode.offsetLeft,
@ -338,12 +338,12 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
} }
} }
if(domNode && domNode.offsetWidth) { if(domNode && ("offsetWidth" in domNode)) {
variables["tv-widgetnode-width"] = domNode.offsetWidth.toString(); variables["tv-widgetnode-width"] = domNode.offsetWidth.toString();
variables["tv-widgetnode-height"] = domNode.offsetHeight.toString(); variables["tv-widgetnode-height"] = domNode.offsetHeight.toString();
} }
if(event && event.clientX && event.clientY) { if(event && ("clientX" in event) && ("clientY" in event)) {
if(selectedNode) { if(selectedNode) {
// Add variables for event X and Y position relative to selected node // Add variables for event X and Y position relative to selected node
selectedNodeRect = selectedNode.getBoundingClientRect(); selectedNodeRect = selectedNode.getBoundingClientRect();