html fragment & html template & virtual DOM

https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template

Fragment


const dom = document.querySelector('#list'); const fruits = ['Apple', 'Orange', 'Banana', 'Melon']; const fragment = new DocumentFragment() fruits.forEach(function (fruit) {
let li = document.createElement('li');
li.innerHTML = fruit;
fragment.appendChild(li);
}) dom.appendChild(fragment);

template

// Test to see if the browser supports the HTML template element by checking
// for the presence of the template element's content attribute.
if ('content' in document.createElement('template')) { // Instantiate the table with the existing HTML tbody
// and the row with the template
const template = document.querySelector('#productrow'); // Clone the new row and insert it into the table
let tbody = document.querySelector("tbody");
let clone = document.importNode(template.content, true); let td = clone.querySelectorAll("td");
td[0].textContent = "1235646565";
td[1].textContent = "Stuff"; tbody.appendChild(clone); // Clone the new row and insert it into the table
let clone2 = document.importNode(template.content, true); td = clone2.querySelectorAll("td");
td[0].textContent = "0384928528";
td[1].textContent = "Acme Kidney Beans 2"; tbody.appendChild(clone2); } else {
// Find another way to add the rows to the table because
// the HTML template element is not supported.
}

slot

web components

https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_templates_and_slots

web components

custom element

https://developer.mozilla.org/en-US/docs/Web/Web_Components

refs

html fragment & html template & virtual DOM

https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template

Fragment


const dom = document.querySelector('#list'); const fruits = ['Apple', 'Orange', 'Banana', 'Melon']; const fragment = new DocumentFragment() fruits.forEach(function (fruit) {
let li = document.createElement('li');
li.innerHTML = fruit;
fragment.appendChild(li);
}) dom.appendChild(fragment);

template

// Test to see if the browser supports the HTML template element by checking
// for the presence of the template element's content attribute.
if ('content' in document.createElement('template')) { // Instantiate the table with the existing HTML tbody
// and the row with the template
const template = document.querySelector('#productrow'); // Clone the new row and insert it into the table
let tbody = document.querySelector("tbody");
let clone = document.importNode(template.content, true); let td = clone.querySelectorAll("td");
td[0].textContent = "1235646565";
td[1].textContent = "Stuff"; tbody.appendChild(clone); // Clone the new row and insert it into the table
let clone2 = document.importNode(template.content, true); td = clone2.querySelectorAll("td");
td[0].textContent = "0384928528";
td[1].textContent = "Acme Kidney Beans 2"; tbody.appendChild(clone2); } else {
// Find another way to add the rows to the table because
// the HTML template element is not supported.
}

slot

web components

https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_templates_and_slots

web components

custom element

https://developer.mozilla.org/en-US/docs/Web/Web_Components

refs

html fragment

html template

virtual DOM

web components

html, fragment, template, virtual DOM, js, svg, HTML5, slot, web components



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


html fragment & html template & virtual DOM & web components的更多相关文章

  1. 前端未来趋势之原生API:Web Components

    声明:未经允许,不得转载. Web Components 现世很久了,所以你可能听说过,甚至学习过,非常了解了.但是没关系,可以再重温一下,温故知新. 浏览器原生能力越来越强. js 曾经的 JQue ...

  2. Web Components All In One

    Web Components All In One Web Components https://www.webcomponents.org/ HTML Template Custom Element ...

  3. 【shadow dom入UI】web components思想如何应用于实际项目

    回顾 经过昨天的优化处理([前端优化之拆分CSS]前端三剑客的分分合合),我们在UI一块做了几个关键动作: ① CSS入UI ② CSS作为组件的一个节点而存在,并且会被“格式化”,即选择器带id前缀 ...

  4. Web Components & HTML template & HTML slot

    Web Components & HTML template & HTML slot https://github.com/xgqfrms/es-next/issues/2 live ...

  5. Web Components & HTML5 & template & slot

    Web Components & HTML5 & template & slot https://developer.mozilla.org/en-US/docs/Web/HT ...

  6. Web Components初探

    本文来自 mweb.baidu.com 做最好的无线WEB研发团队 是随着 Web 应用不断丰富,过度分离的设计也会带来可重用性上的问题.于是各家显神通,各种 UI 组件工具库层出不穷,煞有八仙过海之 ...

  7. The state of Web Components

    Web Components have been on developers’ radars for quite some time now. They were first introduced b ...

  8. 前端应该知道的Web Components

    前端组件化的痛点 在前端组件化横行的今天,确实极大的提升了开发效率.不过有一个问题不得不被重视,拟引入的这些html.css.js代码有可能对你的其他代码造成影响. 虽然我们可以通过命名空间.闭包等一 ...

  9. 一个使用 Web Components 的音乐播放器: MelodyPlayer

    先上效果预览: Web Components 首先,什么是 Web Components ? MDN 给出的定义是: Web Components 是一套不同的技术,允许您创建可重用的定制元素(它们的 ...

随机推荐

  1. 「笔记」AC 自动机

    目录 写在前面 定义 引入 构造 暴力 字典图优化 匹配 在线 离线 复杂度 完整代码 例题 P3796 [模板]AC 自动机(加强版) P3808 [模板]AC 自动机(简单版) 「JSOI2007 ...

  2. 系列trick - 建图

    对偶图 主体思想:平面图的割,等价于对偶图的路 例题:[BeiJing2006]狼抓兔子 网上有114514篇题解,这里不赘述 点变边 主体思想:点带点权,而要在点上实现一些在边上的问题,比如最小割点 ...

  3. Vue技术点整理-vue.config.js

    1,proxy代理解决本地开发环境跨域问题 配置proxy代理后,proxy会将任何未知请求 (没有匹配到静态文件的请求) 代理到 https://192.168.3.49:8080 vue.conf ...

  4. (十一)整合 FastDFS 中间件,实现文件分布式管理

    整合 FastDFS 中间件,实现文件分布式管理 1.FastDFS简介 1.1 核心角色 1.2 运转流程 2.SpringBoot整合FastDFS 2.1 核心步骤 2.2 核心依赖 2.3 配 ...

  5. Java——集合框架之ArrayList,LinkedList,迭代器Iterator

    概述--集合框架 Java语言的设计者对常用的数据结构和算法做了一些规范(接口)和实现(具体实现接口的类).所有抽象出来的数据结构和操作(算法)统称为Java集合框架(Java Collection ...

  6. scala之map,List,:: , +:, :+, :::, +++操作

    scala之map,List操作 1.Map操作 2.List操作 2.1Demo1 2.2Demo2 3.:: , +:, :+, :::, +++ 1.Map操作 Map(映射)是一种可迭代的键值 ...

  7. JS 实现一个实时动态校验,将输入格式错误的显示为红色背景

    功能描述: 源码: 功能描述: 实时动态校验,如果输入的格式错误,将弹窗提示输入格式错误并将背景展示为红色. 源码: 前台: <hy:formfield name="cxfdl&quo ...

  8. size_t 、wchar_t和 ptrdiff_t

    size_t在C语言中就有了. 它是一种"整型"类型,里面保存的是一个整数,就像int, long那样.这种整数用来记录一个大小(size).size_t的全称应该是size ty ...

  9. WLAN参数释义及优化建议

    1.AP覆盖范围或天线角度 1)参数释义 AP覆盖范围或天线角度直接影响到了终端连接到WLAN的信号强度. 2)优化建议 在设备的工程安装过程中,合理选择AP的位置,合理调整AP的覆盖方向或外置天线的 ...

  10. Codeforces Global Round 11 C. The Hard Work of Paparazzi(dp/最长上升子序列)

    题目链接:https://codeforces.com/contest/1427/problem/C 题意 \(r\) 行与 \(r\) 列相交形成了 \(r \times r\) 个点,初始时刻记者 ...