Skip to content

Commit

Permalink
LibWeb: Implement HTMLFormElement.enctype
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonbooth authored and awesomekling committed May 26, 2024
1 parent a8ef84f commit aeb815c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Tests/LibWeb/Text/expected/HTML/form-element-enctype.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enctype | application/x-www-form-urlencoded

enctype | text/plain

enctype | application/x-www-form-urlencoded
18 changes: 18 additions & 0 deletions Tests/LibWeb/Text/input/HTML/form-element-enctype.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<form id="testForm"></form>
<script src="../include.js"></script>
<script>
test(() => {
const form = document.getElementById('testForm');

println(`enctype | ${form.enctype}`);
println('');

form.enctype = 'text/plain';

println(`enctype | ${form.enctype}`);
println('');

form.enctype = 'invalid-value';
println(`enctype | ${form.enctype}`);
});
</script>
10 changes: 9 additions & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#import <DOM/HTMLFormControlsCollection.idl>
#import <HTML/HTMLElement.idl>

// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-enctype
[MissingValueDefault=application/x-www-form-urlencoded, InvalidValueDefault=application/x-www-form-urlencoded]
enum EnctypeAttribute {
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
};

// https://html.spec.whatwg.org/multipage/semantics.html#htmlformelement
[Exposed=Window, LegacyOverrideBuiltIns, LegacyUnenumerableNamedProperties]
interface HTMLFormElement : HTMLElement {
Expand All @@ -10,7 +18,7 @@ interface HTMLFormElement : HTMLElement {
[CEReactions, Reflect=accept-charset] attribute DOMString acceptCharset;
[CEReactions] attribute USVString action;
[FIXME, CEReactions] attribute DOMString autocomplete;
[FIXME, CEReactions] attribute DOMString enctype;
[CEReactions, Enumerated=EnctypeAttribute, Reflect] attribute DOMString enctype;
[FIXME, CEReactions] attribute DOMString encoding;
[CEReactions] attribute DOMString method;
[CEReactions, Reflect] attribute DOMString name;
Expand Down

0 comments on commit aeb815c

Please sign in to comment.