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

Dangling nodes in templates #1

Open
2 tasks done
shgysk8zer0 opened this issue Aug 15, 2017 · 1 comment
Open
2 tasks done

Dangling nodes in templates #1

shgysk8zer0 opened this issue Aug 15, 2017 · 1 comment
Assignees

Comments

@shgysk8zer0
Copy link
Owner

shgysk8zer0 commented Aug 15, 2017

Please check ([x]) all of the following

All other issues will be closed as invalid

  • My issue is with the specification, not with the vocabulary or schemas
  • My issue is not with any particular language or implementation

Describe your issue

How can we specify that a dangling node (belonging to a property but outside) should be removed if properties are missing?

Do you have sample markup & data?

{
    "@type": "Person",
    "@context": "http://schema.org",
    "givenName": "John",
    "familyName": "Smith"
}
<!-- As a template for article authors -->
<div itemtype="http://schema.org/Person" itemscope="">
    By <span itemprop="givenName"></span>
    <span itemprop="familyName"></span>
</div>

If you have any suggestions, please share:

Could add a class name or data-* attribute linking them and require no lose text nodes. That adds
to complexity, but may be required. Would be ideal if <template>s could be structured to avoid this, but I'm not sure it is always possible.

@shgysk8zer0
Copy link
Owner Author

shgysk8zer0 commented Aug 17, 2017

Try this:

if (el.nextSibling.nodeType === Node.TEXT_NODE) {
    el.parentElement.removeChild(el.nextSibling);
}

This would mean that, assuming we can be certain that dangling text nodes need to be removed, it can be easily done without any particular requirements for structure and attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant