mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[ecmascript] querySelector2 example from MDN
This commit is contained in:
parent
0f44179195
commit
e3e7c2cf1a
@ -1150,6 +1150,7 @@ js_element_closest(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst
|
||||
}
|
||||
xmlpp::ustring css = str;
|
||||
xmlpp::ustring xpath = css2xpath(css);
|
||||
|
||||
if (xpath[0] == '/' && xpath[1] == '/')
|
||||
{
|
||||
xpath = xmlpp::ustring("descendant-or-self::") + xpath.substr(2);
|
||||
@ -1506,10 +1507,6 @@ js_element_querySelector(JSContext *ctx, JSValueConst this_val, int argc, JSValu
|
||||
xmlpp::ustring css = str;
|
||||
xmlpp::ustring xpath = css2xpath(css);
|
||||
|
||||
if (xpath[0] == '/' && xpath[1] == '/')
|
||||
{
|
||||
xpath = xmlpp::ustring("descendant-or-self::") + xpath.substr(2);
|
||||
}
|
||||
JS_FreeCString(ctx, str);
|
||||
xmlpp::Node::NodeSet elements;
|
||||
|
||||
@ -1550,11 +1547,6 @@ js_element_querySelectorAll(JSContext *ctx, JSValueConst this_val, int argc, JSV
|
||||
}
|
||||
xmlpp::ustring css = str;
|
||||
xmlpp::ustring xpath = css2xpath(css);
|
||||
|
||||
if (xpath[0] == '/' && xpath[1] == '/')
|
||||
{
|
||||
xpath = xmlpp::ustring("descendant-or-self::") + xpath.substr(2);
|
||||
}
|
||||
JS_FreeCString(ctx, str);
|
||||
xmlpp::Node::NodeSet *elements = new(std::nothrow) xmlpp::Node::NodeSet;
|
||||
|
||||
|
@ -3054,11 +3054,6 @@ element_querySelector(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
jshandle_value_to_char_string(&cssstr, ctx, args[0]);
|
||||
xmlpp::ustring css = cssstr.source;
|
||||
xmlpp::ustring xpath = css2xpath(css);
|
||||
|
||||
if (xpath[0] == '/' && xpath[1] == '/')
|
||||
{
|
||||
xpath = xmlpp::ustring("descendant-or-self::") + xpath.substr(2);
|
||||
}
|
||||
done_string(&cssstr);
|
||||
|
||||
xmlpp::Node::NodeSet elements;
|
||||
@ -3122,11 +3117,6 @@ element_querySelectorAll(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
jshandle_value_to_char_string(&cssstr, ctx, args[0]);
|
||||
xmlpp::ustring css = cssstr.source;
|
||||
xmlpp::ustring xpath = css2xpath(css);
|
||||
|
||||
if (xpath[0] == '/' && xpath[1] == '/')
|
||||
{
|
||||
xpath = xmlpp::ustring("descendant-or-self::") + xpath.substr(2);
|
||||
}
|
||||
done_string(&cssstr);
|
||||
xmlpp::Node::NodeSet *elements = new xmlpp::Node::NodeSet;
|
||||
|
||||
|
18
test/ecmascript/querySelector2.html
Normal file
18
test/ecmascript/querySelector2.html
Normal file
@ -0,0 +1,18 @@
|
||||
<div>
|
||||
<h5>Original content</h5>
|
||||
<p>
|
||||
inside paragraph
|
||||
<span>inside span</span>
|
||||
inside paragraph
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h5>Output</h5>
|
||||
<div id="output"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var baseElement = document.querySelector("p");
|
||||
document.getElementById("output").innerHTML =
|
||||
(baseElement.querySelector("div span").innerHTML);
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user