diff options
Diffstat (limited to 'content/handlers/javascript/duktape/DOMSettableTokenList.bnd')
-rw-r--r-- | content/handlers/javascript/duktape/DOMSettableTokenList.bnd | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/content/handlers/javascript/duktape/DOMSettableTokenList.bnd b/content/handlers/javascript/duktape/DOMSettableTokenList.bnd new file mode 100644 index 000000000..ac5c7062a --- /dev/null +++ b/content/handlers/javascript/duktape/DOMSettableTokenList.bnd @@ -0,0 +1,44 @@ +/* DOMTokenList binding for browser using duktape and libdom + * + * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * Released under the terms of the MIT License, + * http://www.opensource.org/licenses/mit-license + */ + +class DOMSettableTokenList { +}; + +init DOMSettableTokenList(struct dom_tokenlist *tokens::tokens); + +getter DOMSettableTokenList::value() +%{ + dom_exception exc; + dom_string *value; + + exc = dom_tokenlist_get_value(priv->parent.tokens, &value); + if (exc != DOM_NO_ERR) return 0; /* coerced to undefined */ + + duk_push_lstring(ctx, dom_string_data(value), dom_string_length(value)); + dom_string_unref(value); + + return 1; +%} + +setter DOMSettableTokenList::value() +%{ + dom_exception exc; + dom_string *value; + duk_size_t slen; + const char *s = duk_require_lstring(ctx, 0, &slen); + + exc = dom_string_create_interned((const uint8_t *)s, slen, &value); + if (exc != DOM_NO_ERR) return 0; + + exc = dom_tokenlist_set_value(priv->parent.tokens, value); + dom_string_unref(value); + + return 0; +%}
\ No newline at end of file |