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

@html prop renders unexpected tags #57

Closed
rianmurnen opened this issue Oct 21, 2022 · 3 comments
Closed

@html prop renders unexpected tags #57

rianmurnen opened this issue Oct 21, 2022 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rianmurnen
Copy link

rianmurnen commented Oct 21, 2022

Using the @html prop on an element outside a <template> behaves as expected. But when @html is applied inside a <template> the component instance is rendered with unexpected <html>, <head>, and <body> elements.

Package package.json

{
  "name": "learn-webc",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "npx @11ty/eleventy",
    "start": "npx @11ty/eleventy --serve"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@11ty/eleventy": "^2.0.0-canary.16",
    "@11ty/eleventy-plugin-webc": "^0.5.1"
  }
}

Config .eleventy.js

const pluginWebc = require("@11ty/eleventy-plugin-webc");

module.exports = function(eleventyConfig) {
	eleventyConfig.addPlugin(pluginWebc, {
		components: "_includes/webc/*.webc"
	});
};

Layout layout.webc

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<div webc:nokeep @html="content"></div>
</body>
</html>

Page page.webc

---
layout: layout.webc
---
<my-test @text="text"></my-test>

Web Component my-test.webc

<div @html="text"></div>
<template>
    <div @html="text"></div>
</template>

Output

The output as viewed in a text editor, not the browser dev tools. The browser seems to ignore and strip the unexpected elements but they are present in the actual generated file.

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<div>text</div>
<template>
    <div><html><head></head><body>text</body></html></div>
</template>
</body>
</html>

I had the same experience when I downloaded 11ty/demo-webc-counter and ran it without any modification.

@rianmurnen rianmurnen changed the title WebC @html prop renders unexpected tags @html prop renders unexpected tags Oct 21, 2022
@zachleat zachleat self-assigned this Oct 27, 2022
@zachleat zachleat added the bug Something isn't working label Oct 27, 2022
@zachleat
Copy link
Member

@zachleat
Copy link
Member

Regression from #34

@zachleat zachleat added this to the Next Version milestone Oct 27, 2022
@zachleat
Copy link
Member

This will ship with the next version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants