Closed Bug 1660423 Opened 5 years ago Closed 5 years ago

A cloned form has incorrect method.

Categories

(Core :: DOM: Forms, defect)

79 Branch
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: steve, Unassigned)

Details

When I clone an Template which contains a form element with method="PUT" the method property of the clone is returned as "get" [note lowercase]. The attribute list for the clone correctly shows "PUT" .

Inserting the clone into the DOM tree makes no difference

<template id="test">
  <form id="theform" method="PUT">
  </form>
</template>


const templ = document.querySelector('#test');
const cloned = templ.content.cloneNode(true);
const frm = cloned.querySelector("#theform")
console.dir(frm)


Having just reRead the MDN page on Template and seeing a warning about cloning the template itself and click I rewrote the JavaScript to this (long shot). But it still shows method = "get" :(

  const frm = templ.content.firstElementChild.cloneNode(true);
  console.dir(frm.method, frm.attributes.getNamedItem('method').value)

Needinfoing jdai due to recent work on forms.

Flags: needinfo?(jdai)

If this is aimed at me I'm afraid I do not understand.

(In reply to Steve Lee from comment #3)

If this is aimed at me I'm afraid I do not understand.

No, it is a question to John Dai through the "Request information from" feature of bugzilla.

Thank you for reporting this bug. If you tested it without cloned form, it still remains the same result[1]. I think we are following the spec in here. The spec[2] said The method attribute's invalid value default and missing value default are both the GET state. The method="PUT" follows invalid value default case, hence, it returns GET state for you. However, element.attributes is a NamedNodeMap[3], hence, it returns PUT for you. I will mark this bug as invalid, feel free to reopen if you think it's valid. Thank you.

[1] https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=8390
[2] https://html.spec.whatwg.org/#form-submission-attributes
[3] https://dom.spec.whatwg.org/#interface-namednodemap

Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(jdai)
Resolution: --- → INVALID

@jdai Sorry I did not understand PUT is not a valid input! It's a valid HTTP verb and seems the correct one to use when updating an exising resource, Oh well the spec writers know best :)

POST
The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
PUT
The PUT method replaces all current representations of the target resource with the request payload.

Also the return is lowercase get - which is incovenient it would better be Uppercase for the attribute's invalid value as that is better convention.

You need to log in before you can comment on or make changes to this bug.