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

Add rollup, eslint, and matches polyfill #54

Merged
merged 3 commits into from Apr 10, 2017
Merged

Add rollup, eslint, and matches polyfill #54

merged 3 commits into from Apr 10, 2017

Conversation

robdodson
Copy link
Collaborator

Fixes #51

Kind of a big PR, sorry about that.

This switches our build over to using Rollup instead of Gulp. That means we can easily work with ES modules now (if we wanted to break the polyfill into smaller modules we could).

I'm also importing the dom-matches polyfill for IE/Edge support and producing a UMD build which will work standalone or with module loaders like browserify.

Also added ESLint so we could have more consistent PRs. I'm not currently linting the test directory because there were a handful of issues with mocha I didn't feel like resolving at the moment. Kinda want to land this PR first :)

I also killed the inert.min.js build for now because Uglify has issues with module syntax. There's other tools that will do the right thing but I wanted to try doing them in a different PR.

@alice PTAL
@vcorr FYI

"plugins": [
"external-helpers"
]
}
Copy link
Member

Choose a reason for hiding this comment

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

newline?

@@ -0,0 +1,3 @@
rollup.config.js
dist/**/*.js
node_modules/**/*.js
Copy link
Member

Choose a reason for hiding this comment

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

newline? I'm seeing this a lot lately - does VS Code strip EOF newlines by default or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure. Maybe there's a setting I can enable. I'll look

this._observer = new MutationObserver(this._onMutation.bind(this));
this._observer.observe(this._rootElement, { attributes: true, childList: true, subtree: true });
Copy link
Member

Choose a reason for hiding this comment

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

Why remove these spaces? Does ESLint insist on it? Is there an option to make it not do that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's part of the Google ESLint rules:
https://github.com/google/eslint-config-google/blob/master/index.js#L246

"off" or 0 - turn the rule off
"warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)
"error" or 2 - turn the rule on as an error (exit code is 1 when triggered)

src/inert.js Outdated
@@ -109,7 +110,9 @@ class InertRoot {
* @param {Node} startNode
*/
_makeSubtreeUnfocusable(startNode) {
composedTreeWalk(startNode, (node) => { this._visitNode(node); });
composedTreeWalk(startNode, (node) => {
this._visitNode(node);
Copy link
Member

Choose a reason for hiding this comment

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

Hm, remove {}s instead of spreading out over 3 lines?

src/inert.js Outdated
@@ -170,7 +173,9 @@ class InertRoot {
* @param {Node} startNode
*/
_unmanageSubtree(startNode) {
composedTreeWalk(startNode, (node) => { this._unmanageNode(node); });
composedTreeWalk(startNode, (node) => {
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, remove {}s here?

_throwIfDestroyed() {
if (this.destroyed)
throw new Error("Trying to access destroyed InertNode");
throw new Error('Trying to access destroyed InertNode');
Copy link
Member

Choose a reason for hiding this comment

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

Oh no, can we go back to double quotes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

gross but ok :)

Copy link
Member

Choose a reason for hiding this comment

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

Ok let's leave it with single quotes.

@@ -298,9 +303,12 @@ class InertNode {
return this._destroyed;
}

/**
* Throw if user tries to access destroyed InertNode.
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this fairly redundant with the method name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes. the ESLint rules require a JSDoc comment so I just added one in haste.

Copy link
Member

Choose a reason for hiding this comment

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

Totally fair. Maybe just "Once an InertNode is obsolete, accessing any of its members throws an exception. This should never happen in practice." We can update it later tho.

@@ -298,9 +303,12 @@ class InertNode {
return this._destroyed;
}

/**
* Throw if user tries to access destroyed InertNode.
Copy link
Member

Choose a reason for hiding this comment

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

Totally fair. Maybe just "Once an InertNode is obsolete, accessing any of its members throws an exception. This should never happen in practice." We can update it later tho.

@vcorr
Copy link

vcorr commented Apr 11, 2017

The README still refers to inert.min.js
The dist directory contains two versions of the polyfill. inert.js is the debug version, containing an inlined sourcemap, inert.min.js is the production version, minified to be as small as possible.

@robdodson
Copy link
Collaborator Author

good catch, thank you

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.

None yet

3 participants