mootools / mootools-core

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

Js error in Event class #2781

Closed ArmanGrewal closed 7 years ago

ArmanGrewal commented 7 years ago

Hi,

On using new Event (https://developer.mozilla.org/en-US/docs/Web/API/Event/Event) api in independent js file. mootools Event class code is failing on if(type.indexOf('key')==0).

jserror

Thanks

SergioCrisostomo commented 7 years ago

@FEDuser can you provide a jsFiddle reproducing the problem?

DimitarChristoff commented 7 years ago

Can you modify this - https://jsfiddle.net/opc0q95o/ - to show how you use the new Event constructor and how it affects mootools?

ArmanGrewal commented 7 years ago

Here is the scenario - https://jsbin.com/pahibazamu/edit?html,output Third party js is using new Event("something") and It is creating issue in mootools library. mootools_library_error

timwienk commented 7 years ago

This is most likely caused by the fact that you're using MooTools Core with compatibility additions for older versions, you have to choose between compatibility with old MooTools or compliance with newer standards.

Back when MooTools 1.3 was released, there was no native Event object, and MooTools defined its own. In 1.4 MooTools Core's Event object was renamed to DOMEvent.

The Native Event object is overwritten by the compatibility functionality, to make sure MooTools Core is compatible with version 1.3 in this case.

If you do not need compatibility with old MooTools versions, you should not use the "compat" version. You only need the "compat" version if your code is old and/or relies on old code.

ArmanGrewal commented 7 years ago

Thank you. It makes sense. How Can I download nocompat version from https://github.com/mootools/mootools-core/tree/master/Source?

SergioCrisostomo commented 7 years ago

@FEDuser together with the release tag there is a /dist/ folder. You can find it here: https://github.com/mootools/mootools-core/tree/1.6.0/dist

You can also visit the website and download from there: https://mootools.net/core

timwienk commented 7 years ago

Probably easier, you can download it on https://mootools.net/core, or you can build your own version with only what you need on https://mootools.net/core/builder.

Additionally, the CDN you used in your example also distributes the no-compat version:

And so does Google:

ArmanGrewal commented 7 years ago

I want to download a whole folder structure rather than one js file/ cdn js file. Is there any way to download folder structure nocompact version? something like - https://github.com/mootools/mootools-core/tree/master/Source

timwienk commented 7 years ago

There is no file/directory structure without compatibility additions. The compatibility additions are stripped in the packaging/building process.

If you want all source files separately with compatibility stripped, you'll have to do it yourself. You can do that manually, reconfigure (or even adapt) the packager to your needs, or you can try and see if it's doable with the currently available tools.

Perhaps the Advanced Building and Testing part of the README can help.

It's not actually supported, though, and you'll probably be doing a bunch of manual things to get this done.

ArmanGrewal commented 7 years ago

Hi timwienk,

I have one quick question for you. If we use to no compat version, then are we loosing any old browser support(eg: IE8, old safari browsers..)?

Thanks, Armandeep

DimitarChristoff commented 7 years ago

no, just compatibility with old MooTools API.

-- Dimitar Christoff

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