Skip to content

Commit

Permalink
SVG images are interactive
Browse files Browse the repository at this point in the history
Images created with the `image` JME function were all marked as
non-interactive. But SVG images have an event listener attached to the
'load' event to do variable substitution, so they must be considered
interactive.
  • Loading branch information
christianp committed Jan 17, 2025
1 parent 242dbe5 commit c623f83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion runtime/scripts/jme-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,10 @@ newBuiltin('image',[TString, '[number]', '[number]'],THTML,null, {
}
var subber = new jme.variables.DOMcontentsubber(scope);
var element = subber.subvars(img);
element.setAttribute('data-interactive', 'false');

// The subber replaces SVG images with <object> tags which have an event listener for when the content loads, so they must be considered interactive.
element.setAttribute('data-interactive', element.tagName.toLowerCase() == 'object');

return new THTML(element);
}
});
Expand Down
1 change: 0 additions & 1 deletion runtime/scripts/jme-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,6 @@ DOMcontentsubber.prototype = {
return element;
} else if(tagName=='img') {
if(element.getAttribute('src').match(/.svg$/i)) {
element.parentElement
var object = element.ownerDocument.createElement('object');
for(var i=0;i<element.attributes.length;i++) {
var attr = element.attributes[i];
Expand Down

0 comments on commit c623f83

Please sign in to comment.