madkixt / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

addEventListener not reporting errors consistenly across browsers #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When calling addEventListener with two parameters (without the 3rd capture
false argument), different browsers behave differently:
1) Safari accepts this natively (not according to spec)
2) Firefox throws the exception "Not enough arguments" (according to spec)
3) IE accepts this, when base2-dom is being used.

I would expect base2-dom to repair Safari, and to add addEventListener
support to IE according to spec. In this way, develop and test for one
browser, and run without problems (you always hope) on an other browser.

Original issue reported on code.google.com by doek...@gmail.com on 13 Apr 2007 at 8:54

Attachments:

GoogleCodeExporter commented 8 years ago
I might create an optional "strict" lib that can be included when debugging 
otherwise
I don't want to bloat the code with lots of unnecessary checks on arguments.

Original comment by dean.edw...@gmail.com on 1 May 2007 at 8:07

GoogleCodeExporter commented 8 years ago
Maybe it's more a job for a lint, instead of a strict modus... Like the array 
literal [1,2,] will not run in all 
browsers...

Original comment by doek...@gmail.com on 10 Jul 2007 at 9:16

GoogleCodeExporter commented 8 years ago
A debug module could include code like this:

extend(EventTarget, {
    addEventListener: function(target, type, listener) {
        assert(arguments.length >= 3, "Not enough arguments.", SyntaxError);
        assert(target && target.nodeType, "Invalid target.", TypeError);
        assertType(listener, "function");
        return base(this, arguments);
    },

    dispatchEvent: function(target, event) {
        assert(arguments.length >= 2, "Not enough arguments.", SyntaxError);
        return base(this, arguments);
    },

    removeEventListener: function(target, type, listener) {
        assert(arguments.length >= 3, "Not enough arguments.", SyntaxError);
        assertType(listener, "function");
        return base(this, arguments);
    }
});

Original comment by dean.edw...@gmail.com on 12 Jul 2007 at 5:00

GoogleCodeExporter commented 8 years ago
Now I get what you mean.
I'll get to it, when I've got time. Let me own this bug.

Original comment by doek...@gmail.com on 12 Jul 2007 at 5:05

GoogleCodeExporter commented 8 years ago
I checked in some code that you can use as a starting point:

http://base2.googlecode.com/svn/trunk/src/base2/DOM/strict/

Original comment by dean.edw...@gmail.com on 12 Jul 2007 at 8:49

GoogleCodeExporter commented 8 years ago
That pretty much fixes this bug ;-)

But now we have an entry-point for these kind of bugs.

Original comment by doek...@gmail.com on 13 Jul 2007 at 3:12

GoogleCodeExporter commented 8 years ago
Ha ha. I just noticed that my examples are wrong as I'm missing the useCapture
parameter. :-)

Original comment by dean.edw...@gmail.com on 13 Jul 2007 at 3:26

GoogleCodeExporter commented 8 years ago
Brilliant

Original comment by doek...@gmail.com on 13 Jul 2007 at 3:35

GoogleCodeExporter commented 8 years ago
I had to change the title of this. It was bugging me. :-P

Original comment by dean.edw...@gmail.com on 13 Jul 2007 at 5:42

GoogleCodeExporter commented 8 years ago

Original comment by doek...@gmail.com on 14 Jul 2007 at 6:57

GoogleCodeExporter commented 8 years ago
Closing bug.

Original comment by doek...@gmail.com on 14 Jul 2007 at 7:47

GoogleCodeExporter commented 8 years ago
Re-opening bug.

assertArity is not a known function. Is probably in your new lang/main1.js?

And shouldn't we put assertTarget in a seperate file (domAssert.js)?

Original comment by doek...@gmail.com on 21 Jul 2007 at 2:01

GoogleCodeExporter commented 8 years ago
assertArity is there now. Closing bug.

Original comment by dean.edw...@gmail.com on 14 Sep 2007 at 7:23