mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
zjquery: Add closest() method.
This commit is contained in:
committed by
Tim Abbott
parent
b13add3eaf
commit
be527905ca
@@ -163,6 +163,18 @@ exports.make_new_elem = function (selector, opts) {
|
||||
event_store.generic_event('click', arg);
|
||||
return self;
|
||||
},
|
||||
closest: function (selector) {
|
||||
var elem = self;
|
||||
var search = selector.startsWith('.') || selector.startsWith('#') ? selector.substring(1) : selector;
|
||||
if (elem.selector.indexOf(search) > -1) {
|
||||
return elem;
|
||||
} else if (parents_result.get(selector)) {
|
||||
return parents_result.get(selector);
|
||||
} else if (!elem.parent()) {
|
||||
return [];
|
||||
}
|
||||
return elem.parent().closest(selector);
|
||||
},
|
||||
data: noop,
|
||||
delay: function () {
|
||||
return self;
|
||||
|
||||
Reference in New Issue
Block a user