Closed devel-pa closed 9 years ago
Hi @devel-pa,
Fixed and will be released soon, but better to use native .contains
method, see https://developer.mozilla.org/en/docs/Web/API/Node/contains
Thanks, I'll check that too.
Released in 1.0.27
Still crashing if container is an array. My patch:
jBone.contains = function(container, contained) {
var result;
var contains = function(el) {
if (el.contains(contained)) {
return result = el;
}
};
if(container.reverse) {
container.reverse().some(contains);
}
else {
contains(container);
}
return result;
}
I think for you better to improve .find()
method and add support for searching by element.
Because jBone.contains
should work only with DOM elements, not with array or collections (documentation) and looks like polyfill for native .contains
, so I plan to remove it from jBone #48
And if you want to contribute code, welcome for pull requests :)
The method is used by Marionette. Another idea is to override it in jbone-extend and no issue when you'll remove it from jbone.
I have to investigate a bit more, I don't know why I have an array of elements.
Ah, ok, then will keep it.
But override method logic is bad idea. jQuery doesn't take array for $.contains
method, why .find()
method is not suitable for you?
.find
is fine for me, just Marionette is using the .contains
. Maybe I was looking in the wrong place. I have no idea. I'll investigate this evening to see why I need that patch as now looks for me like it make no sense.
ok, so
$.contains
method in jBone..find()
method (allow find by DOM node).Looks like for whatever reason I've put this stupid line in my code:
jBone.contains(jBone(document.documentElement), el)
Like this, where
el
is from a view.