mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[js] publicId
This commit is contained in:
parent
d6df9584c9
commit
8b2ef1ef45
@ -1561,6 +1561,38 @@ doctype_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
doctype_get_property_publicId(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||||
|
{
|
||||||
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
|
/* This can be called if @obj if not itself an instance of the
|
||||||
|
* appropriate class but has one in its prototype chain. Fail
|
||||||
|
* such calls. */
|
||||||
|
if (!JS_InstanceOf(ctx, hobj, &doctype_class, NULL))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
xmlpp::Dtd *dtd = JS_GetPrivate(hobj);
|
||||||
|
|
||||||
|
if (!dtd) {
|
||||||
|
args.rval().setNull();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string v = dtd->get_external_id();
|
||||||
|
args.rval().setString(JS_NewStringCopyZ(ctx, v.c_str()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
doctype_get_property_systemId(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
doctype_get_property_systemId(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||||
{
|
{
|
||||||
@ -1595,6 +1627,7 @@ doctype_get_property_systemId(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
|
|
||||||
JSPropertySpec doctype_props[] = {
|
JSPropertySpec doctype_props[] = {
|
||||||
JS_PSG("name", doctype_get_property_name, JSPROP_ENUMERATE),
|
JS_PSG("name", doctype_get_property_name, JSPROP_ENUMERATE),
|
||||||
|
JS_PSG("publicId", doctype_get_property_publicId, JSPROP_ENUMERATE),
|
||||||
JS_PSG("systemId", doctype_get_property_systemId, JSPROP_ENUMERATE),
|
JS_PSG("systemId", doctype_get_property_systemId, JSPROP_ENUMERATE),
|
||||||
JS_PS_END
|
JS_PS_END
|
||||||
};
|
};
|
||||||
|
21
test/ecmascript/publicId.html
Normal file
21
test/ecmascript/publicId.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<p>Click the button to display the doctype systemId of the document.</p>
|
||||||
|
|
||||||
|
<button onclick="myFunction()">Try it</button>
|
||||||
|
|
||||||
|
<p><strong>Note:</strong> In Internet Explorer 8 and earlier, the doctype property returns <em>null</em> for HTML and XHTML documents, and will only work for XML documents.</p>
|
||||||
|
|
||||||
|
<p id="demo"></p>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function myFunction() {
|
||||||
|
var x = document.doctype.publicId;
|
||||||
|
alert(x);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user