Comments (2)
如果有 named 的 slot,并且 default slot 的内容 trim 之后是 "",那么就忽略 default slot
否则保持原样?
from san.
我试了一下,chrome对slot的支持也是这样的,为了保持一致,就不改了。
测试代码如下:
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body>
<script>
customElements.define('element-details',
class extends HTMLElement {
constructor() {
super();
var template = document
.getElementById('element-details-template')
.content;
const shadowRoot = this.attachShadow({mode: 'open'})
.appendChild(template.cloneNode(true));
}
})
</script>
<template id="element-details-template">
<style>
details {font-family: "Open Sans Light",Helvetica,Arial}
.name {font-weight: bold; color: #217ac0; font-size: 120%}
h4 { margin: 10px 0 -8px 0; }
h4 span { background: #217ac0; padding: 2px 6px 2px 6px }
h4 span { border: 1px solid #cee9f9; border-radius: 4px }
h4 span { color: white }
.attributes { margin-left: 22px; font-size: 90% }
.attributes p { margin-left: 16px; font-style: italic }
</style>
<details>
<summary>
<span>
<code class="name"><<slot name="element-name">NEED NAME</slot>></code>
<i class="desc"><slot name="description">NEED DESCRIPTION</slot></i>
</span>
</summary>
<div class="attributes">
<h4><span>Attributes</span></h4>
<slot name="attributes"><p>None</p></slot>
<div><slot>Default Slot</slot></div>
</div>
</details>
<hr>
</template>
<element-details><span slot="element-name">slot</span><span slot="description">A placeholder inside a web
component that users can fill with their own markup,
with the effect of composing different DOM trees
together.</span></element-details>
</body>
</html>
用chrome看。在 <element-details><span
的 <span
之前加个换行就能看到 Default Slot 不出来了。
from san.
Related Issues (20)
- 如何用打包工具兼容ie8 HOT 2
- defineComponent的interface和实现存在diff
- 请管理员帮忙删除 此 Issue HOT 1
- 循环表格行,表格行中的输入框在数据更新后重置了
- 表达式中的函数必须是先在组件中声明的吗? HOT 2
- 请问san-native后续有开源的计划么? HOT 2
- 条件判断 s-else 节点缺失 props class HOT 1
- 关于调试源码过程中 Data.prototype.splice 方法中的一点疑惑 HOT 2
- san-ssr 可以支持sourcemap吗?
- 有为 vite 提供 san 单文件组件支持的插件吗?
- 在特定情况下created内的数据操作不生效 HOT 2
- 如何使用typescript定义s-ref的类型? HOT 1
- 引入svg标签linearGradient报错
- san支持动态组件吗? HOT 1
- lint: 模板指令是否有推荐的编码规范 HOT 1
- 移除 IE 的支持 HOT 1
- HTML模板可以支持JSX吗 HOT 1
- 条件渲染时,只给其中一个分支标记具名插槽,但其他分支也会被渲染进该具名插槽 HOT 1
- san反解遍历子元素,会移除由空格或换行组成的文本节点,造成页面抖动 HOT 1
- Example中webpack-cli依赖需更新 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from san.