question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.html() is undefined when template root tag is <a>

See original GitHub issue

the html() method returns a undefined when the root tag of a template is a link tag. Vue does not give me any errors but could it be that the root element should not have any bindings attached or so?

Not working example:

    <template>
        <a
            class="teaser__link teaser__posterholder"
            :href="this.href"
            v-if="this.teaser && this.teaser.crops[1]"
        >
            <figure class="poster">
                <div class="poster__placeholder">
                    <img
                        src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
                        :alt="this.title"
                        :data-srcset="teaserImageSrcSet"
                    >
                </div>
            </figure>
        </a>
    </template>

while this is working even the root tag is still not a block tag:

    <template>
        <span>
            <a
                class="teaser__link teaser__posterholder"
                :href="this.href"
                v-if="this.teaser && this.teaser.crops[1]"
            >
               ...........
            </a>
        </span>
    </template>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
eddyerburghcommented, Oct 18, 2017

This should be fixed in 6.0.1 🙌

1reaction
podlebarcommented, Oct 17, 2017

@willypt

here is the component: https://gist.github.com/podlebar/448d11a959a51a7373a71f24b531be7f and here the test: https://gist.github.com/podlebar/469c1764ef2aa3f7c9bd760403ab2c4e

the first span in the component i would like to remove… but when i remove it wrapper.html() is undefined… with span it works good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Error: Template must have exactly one root element" when ...
your indexCtrl is not referenced in your html (ng-controller). You shouldn't init your selected variable with undefined use $scope.selected ...
Read more >
The Content Template element - HTML - MDN Web Docs
The HTML element is a mechanism for holding HTML that is not to be rendered immediately when a page is loaded but may...
Read more >
Handling Null Values in HTML Templates with Angular
Null or undefined values are never in your control when your app is talking to in-house developed APIs or third-party APIs.
Read more >
API - Ractive
This is a collection of helper functions that do things like parse a template, provide instance-free access to cross-instance state, create or augment...
Read more >
Template type checking - Angular
Verifies that component/directive bindings are assignable to their @Input() s; Obeys TypeScript's strictNullChecks flag when validating the preceding mode ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found