PDA

View Full Version : Event handling broken in Beta 3



LesJ
21 Feb 2012, 9:06 AM
I used the Rotate Text component for testing (but you can use any other component).

js\nightly\examples\draw\Rotate Text.html

Run this code:


var snappy = Ext.getCmp('snappy');
snappy.fireEvent('test', snappy);

Event handling works differently between B2 and B3.

Return value:

Beta 2: true
nightly: undefined

I think this has something to do with this code introduced in Beta 3:


Ext.define('Ext.util.Observable', {

constructor: function(config) {
...
// Hash of event "hasListeners" flags.
// For repeated events in time-critical code, the firing code should use
// if (!me.hasListeners.beforerender || me.fireEvent('beforerender', me) !== false) { //code... }
// Bubbling the events counts as one listener.
// The subclass may have already initialized it.
me.hasListeners = me.hasListeners || {};
...
},
....

LesJ
21 Feb 2012, 10:25 AM
I see... this is a feature to improve performance... quite a change though.

hasListener (singular form) would be a better name since we are checking a particular listener, not listeners.

*** EDIT
There's already a method hasListener, so the name of the hash object must be hasListeners.

I guess the hasListener method can now be deprecated.

LesJ
22 Feb 2012, 3:18 AM
Hmm... no comment? This is an API change and it will break some applications.

The Observable.fireEvent method according to the doc returns false if any of the handlers return false otherwise it returns true


But the nightly code returns undefined if there's no listener for the fired event.

Animal
22 Feb 2012, 3:34 AM
We are checking an event, not a particular listener.

We are checking whether an event has listeners

It is not an intentional API change, it's an introduced bug which broke the API.

If there are any listeners they will be called and any that return false will cause a false to be returned.

If there are no listeners, it will return undefined. And that is a bug. I'll create a ticket.

Animal
22 Feb 2012, 3:36 AM
EXTJSIV-5417

nbourdeau
5 Mar 2012, 12:32 PM
EXTJSIV-5417

Hi, I have a licence with you guys with SVN access but I don't seem to see the latest bug fixes and nightly builds ...
Am I missing something ?

skirtle
5 Mar 2012, 8:05 PM
Nightly builds should be downloadable through the support portal. I know this is working fine for most people. There should be a link top-left of the UI. If you can't see it then make sure your browser isn't caching an old version of the page. If that doesn't fix it you'll need to contact Sencha to find out why you haven't been given access.

LesJ
6 Mar 2012, 5:47 AM
Hi, I have a licence with you guys with SVN access but I don't seem to see the latest bug fixes and nightly builds ...
Am I missing something ?

This bug is very easy to work around, just use hasListeners:


Ext.define('Ext.util.Observable', {
...
constructor: function(config) {
var me = this;

Ext.apply(me, config);

// Hash of event "hasListeners" flags.
// For repeated events in time-critical code, the firing code should use
// if (!me.hasListeners.beforerender || me.fireEvent('beforerender', me) !== false) { //code... }
// Bubbling the events counts as one listener.
// The subclass may have already initialized it.
me.hasListeners = me.hasListeners || {};
....

dcoan604
9 Mar 2012, 7:55 PM
I just downloaded 4.1b3 to see how much of my current app would be effected....

Since I use the controller.control() method to attach listeners.... my whole app doesn't work.
I can add listeners and Ext.emptyFn to every component...but that ain't gonna happen.

Is there an override to handle this bug until the next beta release comes?