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 custom element type extensions support #207

Closed
wants to merge 1 commit into from
Closed

add custom element type extensions support #207

wants to merge 1 commit into from

Conversation

rkusa
Copy link

@rkusa rkusa commented Mar 18, 2015

Add support for custom elements extending existing HTML elements, e.g.:

<a is="custom-link">...</a>

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 97.5% when pulling d3cc368 on rkusa:custom-elements into 3f1d123 on Matt-Esch:master.

@neonstalwart
Copy link
Collaborator

got a test?

@neonstalwart
Copy link
Collaborator

the reason i ask about the test is that i believe things will break if you don't have a value for typeExtension. see https://github.com/lhorie/mithril.js/blob/b0f85a71319d9c67ef03786c1c3031e001137070/mithril.js#L258-L259

@rkusa
Copy link
Author

rkusa commented Mar 19, 2015

As of the spec:

Let TYPE be typeExtension, or localName if typeExtension is not present

I did not add a unit test, because it would probably fail on older browsers.
A test snippet (put into the root directory of virtual-dom):

<!DOCTYPE html>
<html>
<head>
  <title>test</title>
  <script type="text/javascript" src="dist/virtual-dom.js"></script>
</head>
<body>
  <script type="text/javascript">
    var proto = Object.create(HTMLAnchorElement.prototype)
    proto.attachedCallback = function() {
      alert('WORKS')
    }

    document.registerElement('custom-link', {
        prototype: proto,
        extends: 'a'
    })

    var h = virtualDom.h
    var tree = h('div', {}, [
      h('a', { attributes: { is: 'custom-link' } }, [String('foo')])
    ])

    document.body.appendChild(virtualDom.create(tree))
  </script>
</body>
</html>

It should alert WORKS.

Thanks for having a look!

@rkusa
Copy link
Author

rkusa commented Mar 19, 2015

Just saw that I get

<a is="A">...</a>

in some browsers. I've updated the PR

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.11%) to 97.38% when pulling 6836ebe on rkusa:custom-elements into 3f1d123 on Matt-Esch:master.

@neonstalwart
Copy link
Collaborator

the code looks good. i just wish there was some way to write a test for this.

@Matt-Esch any thoughts on how to add a test for this?

@rkusa
Copy link
Author

rkusa commented Apr 14, 2015

Anything I can do to help getting this merged? Thanks!

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