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

slimdom 2.0 #28

Merged
merged 34 commits into from
Jun 21, 2017
Merged

slimdom 2.0 #28

merged 34 commits into from
Jun 21, 2017

Conversation

bwrrp
Copy link
Owner

@bwrrp bwrrp commented Jun 14, 2017

This pretty much rewrites the entire codebase to align its behavior with the DOM living standard (as of the current version, last updated 9 May 2017).

TODO before 2.0 release:

  • Implement the "current global object" (i.e., Window in browsers) with an associated document. Use it to implement constructors that behave according to the spec.
  • Get decent coverage by extending the slimdom test suite
  • Write full documentation this time, including API and limitations / deviations from the spec 😄

Nice to have:

@bwrrp
Copy link
Owner Author

bwrrp commented Jun 14, 2017

Fixes #15, #17, #22, #26, #27

This also serves to inject all constructors where possible, avoiding cyclic dependencies.

export function expectObject<T>(value: T, Constructor: any): void {
if (!(value instanceof Constructor)) {
throw new TypeError(`Value should be an instance of ${Constructor.name}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't ask how I know this, but the typescript compiler mangles these properties:
element.appendChild('PRRRRT'); => "Value should be an instance of e"

Copy link
Owner Author

Choose a reason for hiding this comment

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

Fixed :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a couple of tests?

Copy link
Owner Author

Choose a reason for hiding this comment

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

There's one at https://github.com/bwrrp/slimdom.js/blob/align-with-spec/test/Document.tests.ts#L240, although it doesn't test the message.

@bwrrp bwrrp mentioned this pull request Jun 16, 2017
function isElement (node?: Node | null): boolean {
return !!node && node.nodeType === Node.ELEMENT_NODE;
}
export default class Element extends Node implements ParentNode, NonDocumentTypeChildNode, ChildNode {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you consider overriding Function.name as a static property? This should make a dumped object slightly more readable. Also, this will make the asObject function simpler.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Typescript won't let me define a static name property, as it conflicts with the Function.name property. Instead, I've configured the babili minifier to leave the public type names unmangled and restored the old asObject implementation.

@DrRataplan
Copy link
Collaborator

:shipit:

@bwrrp bwrrp merged commit a3ddaff into master Jun 21, 2017
@bwrrp bwrrp deleted the align-with-spec branch June 21, 2017 11:27
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.

2 participants