Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Maintaining the selector property when passing an ender object as argument #196

Open
mariomc opened this issue May 20, 2014 · 3 comments
Open

Comments

@mariomc
Copy link

mariomc commented May 20, 2014

If you pass an ender object as an argument to the ender function, the latter result doesn't maintain the selector property of the previous object.

Take the example:

var x = ender('body');
var y = ender(x);
x.selector; // 'body'
y.selector; // undefined and not 'body'

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/2251601-maintaining-the-selector-property-when-passing-an-ender-object-as-argument?utm_campaign=plugin&utm_content=tracker%2F165667&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F165667&utm_medium=issues&utm_source=github).
@ryanve
Copy link

ryanve commented May 22, 2014

What's your .selector use case? It'd go in the constructor but it seems unneeded because jQuery deprecated .selector.

@mariomc
Copy link
Author

mariomc commented May 29, 2014

Hello @ryanve the use case was strictly for logging/debugging, where a representation of the selector that generated the collection was useful to identify it.

Also in terms of performance, if we have a way to mark the Ender collections - be it selector property or any other - should we need to iterate them again in the constructor?

@ryanve
Copy link

ryanve commented May 29, 2014

@mariomc Consider creating a wrapper around ender() that adds what you need for debugging:

var $ = ender
ender.debug = function() {
  $ = function() {
    var object = ender.apply(this, arguments)
    return object.debug.apply(object, arguments)
  }
}

ender.prototype.debug = function(query, context) {
  // Give `this` extra debugging properties here beforing returning it
  return this
}

Use $ in your code like normal. Call ender.debug() to activate debugging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants