-
Notifications
You must be signed in to change notification settings - Fork 176
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
Use self closing tags so sharif works with XHTML/XML mode #234
Conversation
From #213, comment by @sehkunde
The string is applied as innerHTML to an element and thus parsed by the Browser. If the Browser is in XML compliance mode, this string must be XML compliant. On the other hand, the Browser doesn't have any issues with XML-style self-closed tags in HTML mode.
If content is served as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, we will merge this - I would prefer closing tags to self closing, but that's just my preference :)
I know about XML mode in browsers, but would still be interested in your use-case.
And because this piqued my interest: my reading of the jQuery documentation and some googling on Stack Overflow says:
When the parameter has a single tag (with optional closing tag or quick-closing) —
$( "<img />" ) or $ ( "<img>" ),$( "<a></a>" ) or $ ( "<a>" ) — jQuery creates the element using the native JavaScript .createElement() function.
which your error message about the <ul>
line contradicts ... somethings going on there.
Interesting. And Confusing. If what you said would be what is actually implemented, my change shouldn't have helped at all since both should have triggered the use of createElement. Which actually by itself might be a problem if the HTML comes with the default namespace But it seems like what you found is wrong - or at least no longer how it's implemented. If I didn't misinterpret the code, jQuery uses innerHTML. I only quickly glanced over it though, so maybe I missed something. The dom.js-Implementation shipping now also does not use createElement but innerHTML. |
It's in the current documentation http://api.jquery.com/jQuery/#jQuery2, but I won't dig any further - the |
jquery does indeed use even though, jquery recommends using valid markup:
i think @theseer's approach is the way to go. since shariff only handles the limited scope of putting buttons on a page we'd be doing well to use the most compatible markup and thereby being compatible with xhtml, jquery and our native DOMQuery. regarding details of the matter, @scottschiller did a quite insightful article in 2004. |
This approach looks not very clean to me :/ |
@craiq DOMQuery does not support this syntax because it only implements functions which are actually needed by shariff. |
forgot you changed to this ... Edit: |
While that indeed looks like a clean(er) approach, it would modify how the HTML is constructed rather than just fixing the XHTML/XHTML5 issue. Maybe it's a good additional PR? |
You probably would like to also address the |
This issue should now be solved, see b230e46. |
@pmb0 that's how it looks good :D |
Yes, i know -- good that it's gone. :) |
Changelog: * Added `npm run dev` command. * Added tests for the DOM library. (glaszig) * Added list of supported sharing services to READMEs. * Added `{url}` placeholder to `data-mail-body` option. (stephankellermayr) * Fixed Shariff to use `data-title` in favor of `meta[name=DC.title]` if present. ([#143](#143)) * Fixed Twitter popup opening twice when a tweet is embedded on a page. (Nebel54) * Improved service initialization code. ([#188](#188)) * Made DOM element creation consistent. ([#234](#234)) * tag '1.26.0': release 1.26.0 format changelog
This PR adjusts the way the elements are created to support XHTML/XHTML5.
The strings past in
$('<foo>')
are applied to the innerHTML property and thus, when the browser is in XML mode, likely because the content has been served asapplication/xhtml+xml
or due to the XML header, must be parse-able as XML:The change by this PR is simply closing all elements directly. This works fine as all other changes following are going to be added as children or attributes referencing the newly created node.
Tested in Firefox 52+53 (Linux) and Chrome 57 (Linux).