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

2.0.0 #6

Merged
merged 5 commits into from
Oct 26, 2016
Merged

2.0.0 #6

merged 5 commits into from
Oct 26, 2016

Conversation

jonathantneal
Copy link
Owner

Document Promises 2.0.0 would no longer attach properties to the document by default. This would be because no major browsers have yet implemented the behavior, as discussed in #4. Developers may instead import the features individually and use them as they wish.

// Example ES6 import
import contentLoaded from 'document-promises';

// Example CommonJS import
require('document-promises').contentLoaded;

Which might then be used individually.

contentLoaded.then(function () {
  /* document is ready */
});

Or may be used as polyfills at the developer’s own risk.

document.interactive = interactive;
document.contentLoaded = contentLoaded;
document.loaded = loaded;

@jonathantneal jonathantneal mentioned this pull request Oct 25, 2016
});
};

export let interactive = promisify('readystatechange', /r|m/);
Copy link

@jdalton jdalton Oct 25, 2016

Choose a reason for hiding this comment

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

I know the r|m regexp bit is a clever minifaction.
However, I've seen regexes go wrong with readyState so maybe explicit is better.

For example MDN states that there's loading, interactive, and complete,
but I think IE may have others like uninitialized and loaded.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I’m fine with that. Would something like /^(interactive|complete)$/ and /^complete$/ be sufficient?

I would hope no-one rejects this polyfill because of the additional 10 gzipped bytes it costs to be explicit. And strangely, /^(complete)$/ costs less.

Copy link

@jdalton jdalton Oct 25, 2016

Choose a reason for hiding this comment

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

Yep, yep.
Something like /^(?:interactive|complete)$/ and /^complete$/ would be great!

Copy link
Owner Author

Choose a reason for hiding this comment

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

See 99d2ecf

@@ -50,7 +50,7 @@ contentLoaded.then(function () {
});
```

Developers may also polyfill the proposal at their own risk.
Developers are strongly advised not to assign these promises to `document`, as the standard may still change substantially and such code would be future-incompatible.
Copy link
Owner Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

LGTM, thanks <3

Copy link

@jdalton jdalton Oct 26, 2016

Choose a reason for hiding this comment

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

Since we're dealing in unknowns the bit "would be future-incompatible" should prolly be qualified as "could be future-incompatible".

Copy link

Choose a reason for hiding this comment

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

No, "would" is correct in the context of a clause that starts "the standard may still change substantially".

Copy link

@jdalton jdalton Oct 26, 2016

Choose a reason for hiding this comment

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

I donno, maybe things could evolve in a compatible way (it's an unknown after all).

@jonathantneal jonathantneal merged commit 0c2e5f2 into master Oct 26, 2016
@jonathantneal jonathantneal deleted the feature/ponyfill branch October 26, 2016 03:51
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.

3 participants