diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2022-11-27 14:52:48 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2022-11-27 14:52:48 +0000 |
commit | 550900b1cbfffcd3ceb5c00631bcbae2b453443c (patch) | |
tree | 3dc272c76e0bb76aa1483a7aa346697e4caf6a27 /content/handlers/javascript | |
parent | f29f12a5df255f252987e8acf92994e40125aff6 (diff) | |
download | netsurf-550900b1cbfffcd3ceb5c00631bcbae2b453443c.tar.gz netsurf-550900b1cbfffcd3ceb5c00631bcbae2b453443c.tar.bz2 |
(Element): Honour [SameObject] for ::classList getter
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/javascript')
-rw-r--r-- | content/handlers/javascript/duktape/Element.bnd | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/content/handlers/javascript/duktape/Element.bnd b/content/handlers/javascript/duktape/Element.bnd index 677a9578e..ff0686fd9 100644 --- a/content/handlers/javascript/duktape/Element.bnd +++ b/content/handlers/javascript/duktape/Element.bnd @@ -397,19 +397,29 @@ getter Element::classList () dom_exception exc; dom_tokenlist *tokens; - exc = dom_tokenlist_create((dom_element *)priv->parent.node, corestring_dom_class, &tokens); - if (exc != DOM_NO_ERR) return 0; /* Coerced to undefined */ + duk_set_top(ctx, 0); + duk_push_this(ctx); + duk_get_prop_string(ctx, 0, MAGIC(classList)); - /* Create a settable tokenlist - While the IDL says this isn't settable, all browsers - * seem to make it settable, so we'll permit it too - */ - duk_push_pointer(ctx, tokens); - if (dukky_create_object(ctx, PROTO_NAME(DOMSETTABLETOKENLIST), 1) != DUK_EXEC_SUCCESS) { + if (duk_is_undefined(ctx, -1)) { + duk_pop(ctx); + exc = dom_tokenlist_create((dom_element *)priv->parent.node, corestring_dom_class, &tokens); + if (exc != DOM_NO_ERR) return 0; /* Coerced to undefined */ + + /* Create a settable tokenlist - While the IDL says this isn't settable, all browsers + * seem to make it settable, so we'll permit it too + */ + duk_push_pointer(ctx, tokens); + if (dukky_create_object(ctx, PROTO_NAME(DOMSETTABLETOKENLIST), 1) != DUK_EXEC_SUCCESS) { + dom_tokenlist_unref(tokens); + NSLOG(dukky, DEBUG, "Unable to create DOMSettableTokenList object"); + return 0; /* Coerced to undefined */ + } dom_tokenlist_unref(tokens); - NSLOG(dukky, DEBUG, "Unable to create DOMSettableTokenList object"); - return 0; /* Coerced to undefined */ + duk_dup(ctx, -1); + duk_put_prop_string(ctx, 0, MAGIC(classList)); } - dom_tokenlist_unref(tokens); + return 1; %} |