mootools / mootools-core

MooTools Core Repository
https://mootools.net
2.65k stars 507 forks source link

Mootools does not work in SVG documents #2761

Closed rustyx closed 8 years ago

rustyx commented 8 years ago

Loading Mootools-core in an SVG document fails (in Chrome) with:

Uncaught TypeError: Cannot set property 'color' of undefined(anonymous function) @ MooTools-Core-1.5.2.js:4263

Line 4263 corresponds to:

el.style.color = 'red';

After that I'm not able to use the $ function or any other Mootools function in an SVG.

I'm loading Mootools like this:

<script xlink:href="MooTools-Core-1.5.2.js"/>
DimitarChristoff commented 8 years ago

please use the mail list. this is not a bug. your selector has returned null

rustyx commented 8 years ago

If this is not a bug, what is it, then? Mootools does not support SVG documents? Then this is a feature request. Please reopen.

SergioCrisostomo commented 8 years ago

@rustyx MooTools works with SVG. Please check this jsFiddle: https://jsfiddle.net/rmjwrt59/

If you still have problems, please make a jsFiddle and post in the mailing list, #irc or Stackoverflow.

DimitarChristoff commented 8 years ago

it does support svg. you are calling methods on invalid element objects. make sure your selector can return elements correctly before applying style changes

On Saturday, 26 December 2015, Rustam Abdullaev notifications@github.com wrote:

If this is not a bug, what is it, then? Mootools does not support SVG documents? Then this is a feature request. Please reopen.

— Reply to this email directly or view it on GitHub https://github.com/mootools/mootools-core/issues/2761#issuecomment-167353228 .

Dimitar Christoff

"JavaScript is to JAVA what hamster is to ham" @D_mitar - https://github.com/DimitarChristoff

rustyx commented 8 years ago

jsfiddle is limited to HTML documents, I'm talking about native SVG, not SVG inlined in HTML. Here's an example in which I'm trying to capture some events with MooTools: http://rustyx.org/temp/moosvg.svg

SergioCrisostomo commented 8 years ago

You are using $$('a') before the xml is loaded. Put that code in the end of the page instead.

On Sat, Dec 26, 2015 at 9:47 PM, Rustam Abdullaev notifications@github.com wrote:

jsfiddle is limited to HTML documents, I'm talking about native SVG, not SVG inlined in HTML. Here's an example in which I'm trying to capture some events with MooTools: http://rustyx.org/temp/moosvg.svg

— Reply to this email directly or view it on GitHub https://github.com/mootools/mootools-core/issues/2761#issuecomment-167362003 .

rustyx commented 8 years ago

Moving the code does not help. Also doesn't wrapping it in onload and on-DOMReady as in the examples below... http://rustyx.org/temp/moosvg.svg http://rustyx.org/temp/moosvg2.svg (onload - no luck) http://rustyx.org/temp/moosvg3.svg (DOMReady never fires)

And for completeness, defining SVG onload doesn't work either. http://rustyx.org/temp/moosvg4.svg (using <svg onload=...>)

arian commented 8 years ago

I don't think we've ever tested/tried to use MooTools in SVG documents in this way.

The error comes from a feature detection test, that expects a HTML page. Apparently el = document.createElement('div'); creates a SVG kind of element that does not have the style property like HTML kind elements have.

I'm sure we can fix most errors, but I'm not sure how much work it will to make everything work nicely.