mirror of
https://github.com/rkd77/elinks.git
synced 2024-09-27 02:56:18 -04:00
[mujs] element.querySelector
This commit is contained in:
parent
6f64f8e9db
commit
1b954141eb
@ -28,6 +28,7 @@
|
|||||||
#include "document/libdom/renderer2.h"
|
#include "document/libdom/renderer2.h"
|
||||||
#include "document/view.h"
|
#include "document/view.h"
|
||||||
#include "ecmascript/ecmascript.h"
|
#include "ecmascript/ecmascript.h"
|
||||||
|
#include "ecmascript/ecmascript-c.h"
|
||||||
#include "ecmascript/mujs/mapa.h"
|
#include "ecmascript/mujs/mapa.h"
|
||||||
#include "ecmascript/mujs.h"
|
#include "ecmascript/mujs.h"
|
||||||
#include "ecmascript/mujs/attr.h"
|
#include "ecmascript/mujs/attr.h"
|
||||||
@ -2693,36 +2694,25 @@ mjs_element_querySelector(js_State *J)
|
|||||||
#ifdef ECMASCRIPT_DEBUG
|
#ifdef ECMASCRIPT_DEBUG
|
||||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||||
#endif
|
#endif
|
||||||
// TODO
|
dom_node *el = (dom_node *)(mjs_getprivate(J, 0));
|
||||||
#if 0
|
|
||||||
xmlpp::Element *el = static_cast<xmlpp::Element *>(mjs_getprivate(J, 0));
|
|
||||||
|
|
||||||
if (!el) {
|
if (!el) {
|
||||||
js_pushboolean(J, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const char *str = js_tostring(J, 1);
|
|
||||||
xmlpp::ustring css = str;
|
|
||||||
xmlpp::ustring xpath = css2xpath(css);
|
|
||||||
xmlpp::Node::NodeSet elements;
|
|
||||||
|
|
||||||
try {
|
|
||||||
elements = el->find(xpath);
|
|
||||||
} catch (xmlpp::exception &e) {
|
|
||||||
js_pushnull(J);
|
js_pushnull(J);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const char *selector = js_tostring(J, 1);
|
||||||
|
|
||||||
for (auto node: elements)
|
if (!selector) {
|
||||||
{
|
js_pushnull(J);
|
||||||
if (isAncestor(el, node))
|
|
||||||
{
|
|
||||||
mjs_push_element(J, node);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
void *ret = walk_tree_query(el, selector, 0);
|
||||||
#endif
|
|
||||||
|
if (!ret) {
|
||||||
js_pushnull(J);
|
js_pushnull(J);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mjs_push_element(J, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user