An open API service indexing awesome lists of open source software.

https://github.com/jonmagic/chrome-neighboring-forms-bug


https://github.com/jonmagic/chrome-neighboring-forms-bug

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

          

# Chrome Neighboring Forms Bug

I found what appears to be a bug in Chrome 54, evident when inserting html that contains neighboring forms. In the following example I create a template element, set it's innerHTML to three forms each with their own input field, import the node, and then append it to a container div in the document. The javascript is pretty simple:

```javascript
var container = document.querySelector(".container")
var forms = ""

function prepareNode(html) {
var template = document.createElement("template")
template.innerHTML = html
return document.importNode(template.content, true)
}

container.appendChild(prepareNode(forms))
```

### Safari handles this correctly.

![safari](safari.png)

### But Chrome nests the forms

![chrome](chrome.png)

### The solution

I figured out that nesting each `form` in a `div` will prevent the undesired behavior.