Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Re list bug fix #195

Merged
merged 14 commits into from
Jun 17, 2014
Merged

Re list bug fix #195

merged 14 commits into from
Jun 17, 2014

Conversation

robinedman
Copy link
Contributor

Fixes oja-list-bug #184

Also changes the amd.html example not to use custom elements, as this caused issues when testing this (NSERROR when doing insertOrderedList with the caret at the end of a 1 line paragraph).

@robinedman
Copy link
Contributor Author

I agree that some helpers would be nice (that native API is interesting to put it nicely :)). I like the idea of immutable ones as well . Is there no lightweight library doing this though? (Google mostly points me towards React...)

@OliverJAsh
Copy link
Contributor

@robinedman I had a look around before, it doesn't look like there is anything.

listParentNode.parentNode.insertBefore(listElement, listParentNode.nextElementSibling);
selection.selectMarkers();
listParentNode.parentNode.removeChild(listParentNode);
if (listParentNode.childNodes.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment to say why we do this would be good (because sometimes the paragraph still contains content).

@OliverJAsh
Copy link
Contributor

Nice fix! 👍

@OliverJAsh
Copy link
Contributor

(We’ll wait for the build to finish before merging. See you next year.)

@robinedman
Copy link
Contributor Author

Some libraries here: http://microjs.com/#dom

They generally (maybe always) include things we don't care about though. Possibly if there was one that was good enough, not too weird (thinking of others who want to contribute to Scribe), and that could be custom built with the helpers we want.

@OliverJAsh
Copy link
Contributor

I don't want the monad-like(?) API that libraries such as jQuery provide –
I would prefer just to have functions, i.e. insertAfter(element, afterElement) instead of someWrapper(element).insertAfter(afterElement),
because it’s simpler to start with.

On the other hand, I think front-end uses Zepto for their DOM manipulation.
If we do go with a library, we should consider how this is brought in. A
good example of doing this right is how we bring in Lodash – we use the
lodash-amd project, which lets us require individual functions. I wouldn't
want to bundle in loads of library code we never use.

Oliver Joseph Ash
Software Engineer

On 12 June 2014 15:48, Robin Edman [email protected] wrote:

Some libraries here: http://microjs.com/#dom

They generally (maybe always) include things we don't care about though.
Possibly if there was one that was good enough, not too weird (thinking of
others who want to contribute to Scribe), and that could be custom built
with the helpers we want.


Reply to this email directly or view it on GitHub
#195 (comment).


Visit theguardian.com. On your mobile and tablet, download the Guardian
iPhone and Android apps theguardian.com/guardianapp and our tablet editions
theguardian.com/editions. Save up to 57% by subscribing to the Guardian
and Observer - choose the papers you want and get full digital access.
Visit subscribe.theguardian.com

This e-mail and all attachments are confidential and may also be
privileged. If you are not the named recipient, please notify the sender
and delete the e-mail and all attachments immediately. Do not disclose the
contents to another person. You may not use the information for any
purpose, or store, or copy, it in any way. Guardian News & Media Limited
is not liable for any computer viruses or other material transmitted with
or as part of this e-mail. You should employ virus checking software.

Guardian News & Media Limited is a member of Guardian Media Group plc. Registered
Office: PO Box 68164, Kings Place, 90 York Way, London, N1P 2AP. Registered
in England Number 908396

</rte-toolbar>
<rte></rte>
<div class="rte-toolbar">
<button data-command-name="insertOrderedList">Ol</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to change this?

@OliverJAsh
Copy link
Contributor

Re. immutable helpers, @domenic thinks there could be performance issues: https://twitter.com/domenic/status/477113074235613184. I’m not sure how we can really measure this.

@OliverJAsh
Copy link
Contributor

The build is still running, but the earliest results demonstrate a small problem in Firefox: https://travis-ci.org/guardian/scribe/jobs/27416128

Note: we didn't have a green build to begin with – there is a known failing test on Firefox 23/24/25. We should get around to solving that (separately from this).


if (listElement.nextElementSibling &&
listElement.nextElementSibling.textContent === '') {
listElement.nextElementSibling.parentNode.removeChild(listElement.nextElementSibling);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next sibling will share the same parent, no?

/**
* Chrome: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, the OL/UL will be nested inside the block.
* As per: http://jsbin.com/oDOriyU/1/edit?html,js,output
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not your mistake, but I think the isolated case here should be http://jsbin.com/eFiRedUc/1/edit. Or am I going crazy?

/**
* Chrome 27-34: An empty text node is inserted.
*/
if (listParentNode.childNodes.length === 2 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need to check for childNodes.length === 2 but it does no harm.

@OliverJAsh
Copy link
Contributor

This looks good to me! Nice work 😄

@OliverJAsh
Copy link
Contributor

👍

1 similar comment
@theefer
Copy link
Contributor

theefer commented Jun 17, 2014

👍

@@ -1,7 +1,8 @@
{
"name": "scribe",
"dependencies": {
"lodash-amd": "2.4.1"
"lodash-amd": "2.4.1",
"scribe-common": "0.0.4"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this entry to the package.json file as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out @TooTallNate. I've added it now.

OliverJAsh pushed a commit that referenced this pull request Jun 17, 2014
@OliverJAsh OliverJAsh merged commit 1fb48f9 into master Jun 17, 2014
@OliverJAsh OliverJAsh deleted the re-list-bug-fix branch June 17, 2014 16:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants