There are some breaking changes from v1 to v2 documented at
https://coffeescript.org/#breaking-changes
Most of the changes have to do with this references not being valid
before super is called, as per the es6 spec.
ruby 2.3.4 is EOLed and the old dependencies don't compile on a
modern mac.
uglifier version is pinned down because more recent releases don't
support a copyright option.
The problem:
---
Consider the following HTML:
```html
<form action="/articles" method="post">
<textarea name="content"></textarea>
<button type="submit">Save</button>
</form>
```
Then, consider a theoretical event listener:
```js
addEventListener("keydown", ({ key, metaKey, target }) => {
if (target.form && key == "Enter" && (metaKey || ctrlKey)) {
form.requestSubmit()
}
})
```
This relies on [HTMLTextAreaElement.form][] finding its related `<form>`
element. Given the way the `[form]` attribute can reference a `<form>`
element that is _not an ancestor_, that same event listener would
continue to work with this HTML:
```html
<textarea name="content" form="new_article"></textarea>
<!-- elsewhere -->
<form id="new_article" action="/articles" method="post">
<button type="submit">Save</button>
</form>
```
Unfortunately, if the `<textarea>` element were replaced with a
`<trix-editor>`, the event listener's reliance on accessing the `form`
as a property would break, since the `<trix-editor>` custom element
doesn't declare that property.
[HTMLTextAreaElement.form]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement#properties
The proposed changes:
---
Provide property access for `<trix-editor>` elements, similar to how an
`<input>` or `<textarea>` element can access a form outside of its
direct tree of ancestors via the [form="..."][] attribute and the
corresponding `.form` property.
Related testing changes
---
All other system tests in the suite are rendered into a `<form
id="trix-container">` element on the page. In order to test this new
behavior, the fixture HTML declare several new `<form>` elements.
These are incompatible with an ancestor `<form>`, since HTML forbids
nesting `<form>` elements.
To address that, this commit changes the implementation of how its Test
Helpers create elements from the fixture HTML files.
[form="..."]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-form
* Respect non-empty block elements by allowing them to create a new block, also ensure unwrapped text nodes preceeded by a block element are demarcated with a newline
* Clean up extraneous method
* More robustly, look at the previous sibling rather than element sibling
* Refactor coffeescript to be more pleasing
* Update to ensure we don't create unncessary blocks; instead prefer newlines where possible
* Update test names to be more descriptive
* Add a test for deeply nested divs
* Refactor logic to avoid mocking the guards
* Refactor tests
* Add some intentionally failing tests to investigate
* Skip failing test cases for now
refs: 1f265dd6b8
* Remove extraneous whitespace
Co-authored-by: Javan Makhmali <javan@javan.us>
* Treat pasted URLs as HTML
Addressing feedback comments
* Update test/src/system/pasting_test.coffee
Co-authored-by: Javan Makhmali <javan@javan.us>
Fixing broken test
Removing newline char and space char