Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor of article code #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sukima
Copy link

@sukima sukima commented Jun 3, 2016

I liked the idea that thie article parsing was doing. how it used an iframe to parse the HTML string into DOM and allow the browser to sanitize it before giving it back to Ember. I thought this was a clever way to use Ember client side to parse HTML without the need of a server side proxy.

The code itself bothered me in how it was large functions doing a lot of things with a switch statement driving it all. So I thought it would be a good thought exercise to see how some OOP design practises could make this different.

There was also a bug in the cleaning of an <A> tag. So I split these into two commits. If you felt the refactoring was not a good idea the bug fix can be cherry-picked by itself.

Also, I attempted to test this on my own machine and nothgin worked. My environment is in direct opposition with Ember 1.10 (which at this point is super old!). So hopefully you have a dev environment that actually builds to try it out!

sukima added 2 commits June 3, 2016 08:57
<A> tags don't have a src attribute. This should have been href instead.
The original felt a little out of place. I wanted to encapsulate all the
moving parts into intention revealing names and loose the awkward switch
conditional (which doesn't scale well if new tag cleanup algorithms were
to be introduced).

Using polymorphism helps place the implementation of cleaning specific
types in an encapsulating class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant