This project is archived and is in readonly mode.

#495 ✓resolved

Class.Occlude.occlude @mootools.more alway returns false

Reported by lukasbuenger | January 18th, 2011 @ 07:01 PM | in

The method occlude is supposed to return the occluded element in case of an already cached instance with the given hash property or false if there's no object cached under the given hash property.
However, this method always returns false, which leads to multiple instances of the Class.Occlude-descendant, which is against the functionality concept of the Occlude helper.

To test this, simply log the 2 conditions in the if-statement and instantiate 2 objects of a Class.Occlude-descendant:

Class.Occlude = new Class({
occlude: function(property, element){

    element = || this.element);
    var instance = element.retrieve(property ||;
    console.log (instance, this.occluded != null);
    if (instance && this.occluded != null)
        return this.occluded = instance;

    this.occluded = false; ||, this);
    return this.occluded;

} });
var Widget = new Class({
    Implements: [Class.Occlude],
    property: 'widget',
    initialize: function(element){
        this.element = $(element);
        if (this.occlude()) return this.occluded;
        //returns the instance already bound to the element and exits

var widget1 = new Widget('someDiv');
var widget2 = new Widget('someDiv');
console.log (widget1 == widget2);

I suggest the following solution:

Class.Occlude = new Class({

occlude: function(property, element){
    element = || this.element);
    this.occluded = element.retrieve(property ||;
    if (this.occluded != null)
        return true; ||, this);
    return false;


Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The MooTools Extensions

People watching this ticket

Referenced by