Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_super() not called on "sibling" methods (same specificity) #11

Open
chillu opened this issue Jul 4, 2011 · 0 comments
Open

_super() not called on "sibling" methods (same specificity) #11

chillu opened this issue Jul 4, 2011 · 0 comments

Comments

@chillu
Copy link
Contributor

chillu commented Jul 4, 2011

Failing test for spec.entwine.ctors.js:

it( 'calls duplicate onmatch on same specificity with super', function() {
  var a = 0, b=0;
  $('.foo').entwine({onmatch: function(){a += 1;}})
  $('.foo').entwine({onmatch: function(){b += 1; this._super();}})
  expect([a, b]).toEqual( [0, 0]);
  $('#a').addClass('foo');
  expect([a, b]).toEqual( [1, 1]);
});

Its unclear to me whether this should work. super() seems to be tested for less specific selectors only.
If thats its only intended use case, do we only allow customization of an existing codebase by being more specific?

I have this problem in the CMS at the moment, for isolating features into their own files.
Its misusing entwine a bit by applying stuff to a "base element", but not everything applies directly to a DOM element.

// DOM structure
<body class="LeftAndMain CMSMain">...</body>

// LeftAndMain.js
$('.LeftAndMain').entwine(
    onmatch: function() {
        // setup layout etc. - never called because of LeftAndMain.Ping.js
    }
});

// LeftAndMain.Ping.js
$('.LeftAndMain').entwine(
    onmatch: function() {
        // setup ping
    }
});

// CMSMain.js
$('.CMSMain').entwine(
    onmatch: function() {
        // setup cms specific stuff
        this._super();
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant