JavScript code clash mod_phoca_tree and highcharts.js
Posted: 17 Jan 2022, 23:28
Hi,
I am developing a component J!TrackGallery for Joomla and received a question from a user who uses this in combination with the mod_phoca_tree module.
The issue is a conflict in function/object names: mod_phoca_tree loads the following JavaScript:
which defines a function 'Node' which overrides the standard Node object (https://developer.mozilla.org/en-US/docs/Web/API/Node )
The J!Trackgallery code, uses highcharts for plotting (http://www.highcharts.com, example page: https://jtrackgalleryj4.gta-trek.eu/ind ... g/track/18), which uses win.Node.TEXT_NODE as a named constant (see https://developer.mozilla.org/en-US/doc ... e/nodeType) to identify text objects in the DOM tree. This constant is not defined when the dtree.js file is loaded.
dtree.js does not seem to be part of the source of the mod_phocagallery_tree. Is it generated by jstree?
I am not a JavaScript expert; is there a way to avoid this clash in the global namespace?
Best regards, Marco.
I am developing a component J!TrackGallery for Joomla and received a question from a user who uses this in combination with the mod_phoca_tree module.
The issue is a conflict in function/object names: mod_phoca_tree loads the following JavaScript:
Code: Select all
$document->addScript( JURI::base(true) . '/media/mod_phocagallery_tree/dtree.js' );
The J!Trackgallery code, uses highcharts for plotting (http://www.highcharts.com, example page: https://jtrackgalleryj4.gta-trek.eu/ind ... g/track/18), which uses win.Node.TEXT_NODE as a named constant (see https://developer.mozilla.org/en-US/doc ... e/nodeType) to identify text objects in the DOM tree. This constant is not defined when the dtree.js file is loaded.
dtree.js does not seem to be part of the source of the mod_phocagallery_tree. Is it generated by jstree?
I am not a JavaScript expert; is there a way to avoid this clash in the global namespace?
Best regards, Marco.