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

Polymer should respect XHTML syntax #680

Closed
tigerhawkvok opened this issue Aug 3, 2014 · 3 comments
Closed

Polymer should respect XHTML syntax #680

tigerhawkvok opened this issue Aug 3, 2014 · 3 comments

Comments

@tigerhawkvok
Copy link

Right now, Polymer fails with self-closing tags, eg

<polymer-tag></polymer-tag>

must be used, as

<polymer-tag/>

fails to render correctly, despite being valid XHTML.

@ebidel
Copy link
Contributor

ebidel commented Aug 3, 2014

Unfortunately, the HTML spec/parser only allows a certain few tags to be self-closing, so can't create new ones using custom elements. You can however piggyback of a self closing tag by creating a type extension custom element. See http://echelog.com/logs/browse/polymer/1379282400.

Closing this as Polymer can't do much about it.

@ebidel ebidel closed this as completed Aug 3, 2014
@tigerhawkvok
Copy link
Author

Interesting. So you can't register a void element, but it needs to be void for the HTML parser to accept a self-close.

I'll test it with the XML parser and see how it behaves there, and update this thread for information's sake, even though you've closed it.

@tigerhawkvok
Copy link
Author

So, serving the page as XHTML will permit self-closing tags, BUT breaks some scripts.

For example, I created this element:

<link rel="import" href="../bower_components/polymer/polymer.html"/>
<polymer-element name="copyright-statement" attributes="copyrightStart">
  <template>
    <span>
      &#169; {{copyrightStart}}{{thisYear}}
    </span>
  </template>
  <script>
    Polymer('copyright-statement',{
        copyrightStart:2014,
        created: function() {
            console.log("The copyright-statement has been registered.");
        },
        ready: function() {
            this.thisYear = new Date().getFullYear();
            if(this.copyrightStart != null) {
                if(parseInt(this.copyrightStart) < this.thisYear) {
                    this.copyrightStart = this.copyrightStart + " \u2014 ";
                } else {
                    this.copyrightStart = "";
                }
            }
        }
    });
  </script>
</polymer-element>

In HTML mode, this:

<copyright-statement copyrightStart="2013"></copyright-statement>

outputs

© 2013 — 2014

But in XHTML mode, this:

<copyright-statement copyrightStart="2013"/>

only outputs

© 2014

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

No branches or pull requests

2 participants