{"id":346,"date":"2014-10-16T09:41:26","date_gmt":"2014-10-16T01:41:26","guid":{"rendered":"http:\/\/www.daliane.com\/?p=346"},"modified":"2014-10-16T09:42:36","modified_gmt":"2014-10-16T01:42:36","slug":"web_components_shi_shen_me","status":"publish","type":"post","link":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/web_components_shi_shen_me\/","title":{"rendered":"Web Components\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<div class=\"topic_detail\">\n<div class=\"topic_info clearfix\"><\/div>\n<div class=\"callout\">\n<h3 id=\"web-components-\">Web Components \u7684\u73b0\u72b6<\/h3>\n<p>\u5230\u76ee\u524d\u4e3a\u6b62,<code>w3c<\/code>\u5b9a\u4e49\u7684<code>web components<\/code>\u5df2\u7ecf\u5305\u542b\u4e86<\/p>\n<ul>\n<li><code>Templates<\/code>, \u63d0\u4f9b\u4e00\u4e2a\u5305\u542bhtml,css,js\u7684\u4ee3\u7801\u7247\u6bb5,\u7c7b\u4f3c\u4e8e\u4e00\u822c\u6a21\u677f\u5f15\u64ce\u91cc\u7684\u89c6\u56fe<\/li>\n<li><code>Custom Elements<\/code>, \u63d0\u4f9b\u4e00\u4e2a\u81ea\u5b9a\u4e49html\u5143\u7d20\u7684\u63a5\u53e3\uff0c\u652f\u6301\u5bf9\u73b0\u6709html\u5143\u7d20\u7684\u6269\u5c55<\/li>\n<li><code>Imports<\/code>, \u63d0\u4f9b\u5bf9\u6a21\u677f\u6216\u8005\u81ea\u5b9a\u4e49\u5143\u7d20\u8fd9\u4e9b\u8d44\u6e90\u7684\u52a0\u8f7d\u652f\u6301<\/li>\n<li><code>Shadow DOM<\/code>, \u63d0\u4f9b\u4e00\u4e2a\u5bf9\u5916\u9690\u85cf\u7684web\u7247\u6bb5,\u800c\u4e14\u652f\u6301\u72ec\u7acb\u7684\u6837\u5f0f,\u4e0d\u4f1a\u7834\u574f\u6587\u6863\u5185\u7684\u6837\u5f0f<\/li>\n<\/ul>\n<p>web \u7ec4\u4ef6\u7684\u6280\u672f\u89c4\u8303\u7684\u5236\u5b9a\u5c31\u662f\u4e3a\u4e86\u4fdd\u8bc1\u524d\u7aef\u7ec4\u4ef6\u7684\u89c4\u8303\u5316\uff0c\u72ec\u7acb\u6027\uff0c\u53ef\u91cd\u7528\u6027.\u5148\u6765\u8bf4\u8bf4<code>Templates<\/code>\u529f\u80fd<\/p>\n<hr \/>\n<h3 id=\"templates\">Templates<\/h3>\n<p><code>Templates<\/code>\u63d0\u4f9b\u4e86\u7c7b\u4f3c\u4e8e\u6a21\u677f\u5f15\u64ce\u91cc\u7684\u89c6\u56fe\u529f\u80fd,\u9ed8\u8ba4\u6d4f\u89c8\u5668\u662f\u4e0d\u4f1a\u6e32\u67d3\u6b64\u6807\u7b7e\u7684\u5185\u5bb9\u7684,\u53ea\u6709\u5f53\u4f60\u771f\u6b63\u7528\u7684\u65f6\u5019\u624d\u4f1a\u53bb<code>render<\/code>,\u4e0b\u9762\u7ed9\u4e00\u4e2a\u7b80\u5355\u7684\u4f7f\u7528<code>Templates<\/code>\u7684\u4f8b\u5b50<\/p>\n<pre><code class=\"lang-html\">\r\n&lt;template id=\"foo\"&gt;\r\n    &lt;h2&gt;Hello, world!&lt;\/h2&gt;\r\n&lt;\/template&gt;\r\n<\/code><\/pre>\n<p>\u8ddf\u666e\u901a\u7684html\u6807\u7b7e\u4e00\u6837\uff0c\u5b9a\u4e49\u4e00\u4e2aid\u6765\u6807\u8bc6\u8fd9\u6bb5\u4ee3\u7801,\u4e0b\u9762\u6211\u4eec\u6765\u4f7f\u7528\u8fd9\u4e2a\u6a21\u677f<\/p>\n<pre><code class=\"lang-js\">\r\nvar template = document.querySelector('#foo');\r\ndocument.querySelector('body').appendChild(template.content.cloneNode(true));\r\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u5c31\u662f\u5f80body\u91cc\u63d2\u5165\u6a21\u677f\u91cc\u7684\u5185\u5bb9,\u8fd9\u91cc\u8981\u6ce8\u610f\u4e0b,\u60f3\u8981\u83b7\u53d6\u6a21\u677f\u5185\u7684\u5185\u5bb9,\u5f97\u4f7f\u7528\u6a21\u677f\u5143\u7d20\u7684<code>content<\/code>\u5c5e\u6027,\u5185\u5bb9\u7684\u7c7b\u578b\u662f<code>documentFragment<\/code>\uff0c\u4e00\u822c\u5728\u540c\u65f6\u63d2\u5165\u591a\u4e2ahtml\u5185\u5bb9\u7684\u65f6\u5019\uff0c\u7528<code>documentFragment<\/code>\u662f\u6700\u6709\u6548\u7387\u7684, \u8fd9\u91cc\u8fd8\u8981\u6ce8\u610f\u4e0b\uff0c\u5047\u5982\u76f4\u63a5\u628a<code>content<\/code>\u7684\u5185\u5bb9\u63d2\u5165\u5230\u76ee\u6807\u5143\u7d20\u5185\u4e4b\u540e\uff0c\u6a21\u677f\u7684\u5185\u5bb9\u5c31\u4f1a\u4e22\u5931\uff0c\u6240\u4ee5\u4e3a\u4e86\u4fdd\u8bc1\u522b\u7684\u76ee\u6807\u5143\u7d20\u4e5f\u60f3\u63d2\u5165\u8fd9\u4e2a\u6a21\u677f\u7684\u8bdd\uff0c\u53ef\u4ee5\u4f7f\u7528<code>Node<\/code>\u7684<code>cloneNode<\/code>\u65b9\u6cd5\uff0c\u8fd9\u662f\u6240\u6709html\u8282\u70b9\u90fd\u6709\u7684\u65b9\u6cd5,\u53c2\u6570\u4f20\u9012<code>true<\/code>\u7684\u8bdd\u4f1a\u6df1\u5ea6clone.<\/p>\n<h3 id=\"custom-elements\">Custom Elements<\/h3>\n<p>\u81ea\u5b9a\u4e49\u5143\u7d20api\u63a5\u53e3\u63d0\u4f9b\u4e86\u4e00\u4e2a\u53ef\u4ee5\u81ea\u5b9a\u4e49html\u5143\u7d20\u7684\u65b9\u6cd5\uff0c\u652f\u6301\u65b0\u589e\u65b9\u6cd5\u4ee5\u53ca\u5bf9\u73b0\u6709\u7684\u5143\u7d20\u8fdb\u884c\u6269\u5c55<\/p>\n<p><code>w3c<\/code>\u63d0\u4f9b\u4e86<code>document.registerElement<\/code>\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u5143\u7d20,\u5148\u6765\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u4f8b\uff0c\u7136\u540e\u518d\u5206\u6790\u5b83\u7684\u5b9e\u73b0<\/p>\n<pre><code class=\"lang-js\">var p = Object.create(HTMLElement.prototype);\r\np.hello = function () {\r\n    this.appendChild(\"&lt;h1&gt;hello feenan&lt;\/h1&gt;\");\r\n}\r\nvar HelloFeenan = document.registerElement('hello-feenan', {prototype: p});\r\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u521b\u5efa\u4e00\u4e2a\u540d\u53eb<code>hello-feenan<\/code>\u7684\u5143\u7d20,\u81ea\u5b9a\u4e49\u7684\u5143\u7d20\u5fc5\u987b\u4ee5<code>-<\/code>\u6765\u8fde\u63a5,<code>Object.create<\/code>\u4f20\u9012\u4e00\u4e2a\u539f\u578b\uff0c\u5c06\u4f1a\u521b\u5efa\u7ee7\u627f\u8fd9\u4e2a\u539f\u578b\u7684\u5bf9\u8c61,\u7136\u540e\u5bf9\u8fd9\u4e2a\u539f\u578b\u8fdb\u884c\u65b9\u6cd5\u6269\u5c55\uff0c\u8fd9\u91cc\u52a0\u4e86\u4e00\u4e2a<code>hello<\/code>\u65b9\u6cd5,\u5b9a\u4e49\u5b8c\u8fd9\u4e2a\u5143\u7d20\u4e4b\u540e\uff0c\u600e\u4e48\u4f7f\u7528\u5462,\u5176\u5b9e\u5b83\u8ddf\u7cfb\u7edf\u81ea\u5e26\u7684\u5143\u7d20\u4e00\u6837\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728html\u9875\u91cc\u4f7f\u7528\u4e5f\u53ef\u4ee5\u52a8\u6001\u7684\u6dfb\u52a0\uff0c\u8fd9\u91cc\u4f7f\u7528<code>document.createElement<\/code>\u65b9\u6cd5\u6765\u6dfb\u52a0\uff0c\u7136\u540e\u52a8\u6001\u7684\u6dfb\u52a0<code>body<\/code>\u5143\u7d20\u4e2d<\/p>\n<pre><code class=\"lang-js\">var el = document.createElement('hello-feenan');\r\n\r\ndocument.querySelector('body').appendChild(el);\r\n\r\n\/\/ \u8c03\u7528hello\u65b9\u6cd5\u6765\u6dfb\u52a0\u5b50\u5143\u7d20\r\ndocument.querySelector('hello-feenan').hello();\r\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u5c31\u662f\u5e94\u7528\u81ea\u5b9a\u4e49\u5143\u7d20\u7684\u597d\u4f8b\u5b50,\u5176\u5b9e\u8fd9\u91cc\u7684<code>hello<\/code>\u65b9\u6cd5\u7684\u5185\u5bb9\u53ef\u4ee5\u5728\u81ea\u5b9a\u4e49\u5143\u7d20\u7684\u521d\u59cb\u5316\u4e8b\u4ef6\u56de\u8c03\u91cc\u6267\u884c,\u8bf4\u5230\u8fd9\u91cc,\u5c31\u5f97\u63d0\u63d0<code>customer element<\/code> \u7684\u652f\u6301\u7684\u4e8b\u4ef6\u4e86<\/p>\n<ul>\n<li>createdCallback \u81ea\u5b9a\u4e49\u5143\u7d20\u521b\u5efa\u5b9e\u4f8b\u7684\u65f6\u5019\u89e6\u53d1<\/li>\n<li>attachedCallback \u5f53\u5143\u7d20\u5b9e\u4f8b\u88ab\u6dfb\u52a0\u5230<code>document<\/code>\u6587\u6863\u6d41\u4e2d\u65f6\u89e6\u53d1<\/li>\n<li>detachedCallback \u5f53\u4ece<code>document<\/code>\u6587\u6863\u6d41\u4e2d\u5220\u9664\u81ea\u5b9a\u4e49\u7684\u5143\u7d20\u5b9e\u4f8b\u65f6\u89e6\u53d1<\/li>\n<li>attributeChangedCallback \u5f53\u5143\u7d20\u5b9e\u4f8b\u7684\u5c5e\u6027\u4fee\u6539\u7684\u65f6\u5019\u89e6\u53d1<\/li>\n<\/ul>\n<p>\u8fd9\u56db\u4e2a\u4e8b\u4ef6\u7684\u56de\u8c03\u51fd\u6570\u5fc5\u987b\u5b9a\u4e49\u5728\u81ea\u5b9a\u4e49\u5143\u7d20\u7684\u539f\u578b\u5bf9\u8c61\u4e0a\u9762\uff0c\u6bd4\u5982\u4e0a\u9762\u7684<code>p<\/code>,\u53ef\u4ee5\u901a\u8fc7<code>createdCallback<\/code>\u4e8b\u4ef6\u6765\u5b9e\u73b0\u4e0a\u9762\u7684<code>hello<\/code>\u65b9\u6cd5\u7684\u5185\u5bb9<\/p>\n<pre><code class=\"lang-js\">p.createdCallback = function(){\r\n    this.appendChild(\"&lt;h1&gt;hello feenan&lt;\/h1&gt;\");\r\n}\r\n<\/code><\/pre>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u5e26\u81ea\u5b9a\u4e49\u5143\u7d20\u5b9e\u73b0\u7684\u4f8b\u5b50<\/p>\n<pre><code class=\"lang-html\">&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;title&gt;customer elements&lt;\/title&gt;\r\n        &lt;meta charset=\"utf-8\"&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;script&gt;\r\n\r\n            var helloFeenan = Object.create(HTMLElement.prototype);\r\n\r\n            helloFeenan.hello = function(){\r\n                this.appendChild(\"&lt;h1&gt;hello feenan&lt;\/h1&gt;\");\r\n            }\r\n\r\n            \/\/ \u5f53\u5143\u7d20\u88ab\u521b\u5efa\u7684\u65f6\u5019\u89e6\u53d1\u6b64\u56de\u8c03\u51fd\u6570\r\n            helloFeenan.createdCallback = function(){\r\n                this.appendChild(\"&lt;h1&gt;hello feenan&lt;\/h1&gt;\");\r\n            }\r\n            document.registerElement('hello-feenan', { prototype: helloFeenan});\r\n\r\n            var el = document.createElement('hello-feenan');\r\n\r\n            document.querySelector('body').appendChild(el);\r\n\r\n\r\n        &lt;\/script&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<h3 id=\"imports\">Imports<\/h3>\n<p><code>imports<\/code>\u7279\u6027\u63d0\u4f9b\u4e86\u4ee5<code>link<\/code>\u65b9\u5f0f\u6765\u5bfc\u5165\u4e00\u6bb5html\u6587\u672c\u7684\u529f\u80fd,\u76f8\u5f53\u4e8e\u662f<code>template<\/code>\u7684\u8fdb\u5316\u7248,\u65b9\u4fbf\u505a\u6210\u6a21\u677f\u6587\u4ef6<\/p>\n<p><code>w3c<\/code>\u89c4\u5b9a<code>link<\/code>\u7684<code>rel<\/code>\u5c5e\u6027\u4f20\u5165<code>import<\/code>\u503c,\u7136\u540e\u8bbe\u7f6e<code>src<\/code>\u4e3a\u4e00\u4e2a<code>html<\/code>\u6587\u4ef6,\u50cf\u4e0b\u9762\u8fd9\u6837\u7684<\/p>\n<pre><code class=\"lang-html\">\r\n&lt;link rel=\"import\" href=\"import.html\"&gt;\r\n<\/code><\/pre>\n<p>\u90a3\u4e48\u5728\u5f15\u5165\u9875\u9762\u7684<code>dom<\/code>\u91cc\u600e\u4e48\u83b7\u53d6\u5bfc\u5165\u7684\u6587\u4ef6\u5185\u5bb9\u5462,<code>w3c<\/code>\u7ed9<code>rel=import<\/code>\u7684\u5143\u7d20\u63d0\u4f9b\u4e86<code>import<\/code>\u5c5e\u6027\u6765\u83b7\u53d6\u6587\u4ef6\u5185\u5bb9,\u672c\u8d28\u4e0a\u662f<code>#document<\/code>\u7c7b\u578b,\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u6765\u83b7\u53d6\u5185\u5bb9<\/p>\n<pre><code class=\"lang-js\">\r\nvar link = $('link[rel=import]')[0];\r\n\r\nvar link_doc = link.import;\r\n<\/code><\/pre>\n<h3 id=\"shadow-dom\">Shadow DOM<\/h3>\n<p><code>shadow dom<\/code>\u6839\u636e\u5b57\u9762\u610f\u601d\u5c31\u77e5\u9053\u8fd9\u662f\u9690\u85cf\u5728<code>dom<\/code>\u8282\u70b9\u91cc\u7684\u5143\u7d20,\u63d0\u4f9b\u4e86\u5bf9<code>css,js,html<\/code>\u7684\u5c01\u88c5\u4ece\u800c\u5f62\u6210\u4e00\u4e2a\u72ec\u7acb\u7ec4\u4ef6\u7684\u529f\u80fd,\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u4e0d\u9519\u7684\u7279\u6027,\u7ed3\u5408<code>import<\/code>\u53ef\u4ee5\u5b9e\u73b0\u4e00\u4e2a\u53ef\u91cd\u7528\u7684Web\u7ec4\u4ef6\u529f\u80fd\u66ff\u4ee3\u73b0\u5728\u7684\u4e00\u4e9bui\u7ec4\u4ef6.<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u6765\u770b\u770b\u600e\u4e48\u4f7f\u7528<code>shadow dom<\/code><\/p>\n<p><code>w3c<\/code>\u63d0\u4f9b\u4e86<code>createShadowRoot<\/code>\u65b9\u6cd5,\u8fd9\u5c5e\u4e8e<code>element<\/code>\u7684\u65b9\u6cd5,\u5728\u5143\u7d20\u4e0a\u9762\u8c03\u7528\u8fd9\u4e2a\u65b9\u6cd5\u5c06\u5728\u5b83\u4e0b\u9762\u521b\u5efa<code>shadow dom<\/code>\u5b50\u5143\u7d20,\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u6765\u4f7f\u7528<\/p>\n<pre><code class=\"lang-js\">\r\nvar shadowroot = $('.content')[0].createShadowRoot();\r\nvar elm = document.createElement('h1');\r\nelm.textConent = 'hello feenan';\r\nshadowroot.appendChild(elm);\r\n<\/code><\/pre>\n<h3 id=\"-\">\u4e00\u4e2a\u5b8c\u6574\u7684\u4f8b\u5b50<\/h3>\n<p>\u76ee\u524d<code>chrome 36<\/code> \u5df2\u5bf9<code>template, import, shadow dom<\/code>\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u652f\u6301\uff0c\u6240\u4ee5\u4e0b\u9762\u63d0\u4f9b\u4e00\u4e2a\u7ed3\u5408\u4e09\u8005\u7684\u4f8b\u5b50<\/p>\n<ul>\n<li>link\u5143\u7d20\u9700\u8981\u5f15\u5165\u7684import.html\u6587\u4ef6<\/li>\n<\/ul>\n<pre><code class=\"lang-html\">\r\n&lt;style&gt;\r\n    .content{\r\n        margin: 20px;padding: 15px;\r\n        width: 200px;height: 200px;\r\n        border: 1px solid #ccc;border-radius: 5px;\r\n        box-shadow: 0 0 10px red;\r\n        overflow: auto;\r\n    }\r\n&lt;\/style&gt;\r\n&lt;div class=\"content\"&gt;\r\n    &lt;h2&gt;this is a test for ShadowRoot&lt;\/h2&gt;\r\n&lt;\/div&gt;\r\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u6587\u4ef6,<code>chrome<\/code>\u5728\u7528<code>link<\/code>\u5f15\u5165\u4e4b\u540e,\u6837\u5f0f\u6587\u4ef6\u4f1a\u653e\u5728<code>link.import<\/code>\u7684<code>document<\/code>\u91cc\u7684<code>head<\/code>\u5143\u7d20\u5185,\u666e\u901a<code>html<\/code>\u5143\u7d20\u4f1a\u653e\u5165<code>body<\/code>\u4e2d\uff0c\u77e5\u9053\u4e86\u5185\u5bb9\u7684\u4f4d\u7f6e\uff0c\u65b9\u4fbf\u4e0b\u9762\u7528\u7684\u65f6\u5019\u67e5\u627e<\/p>\n<ul>\n<li>index.html \u8fd0\u884c\u4f8b\u5b50\u7684\u4e3bhtml\u6587\u4ef6<\/li>\n<\/ul>\n<pre><code class=\"lang-html\">\r\n&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;web components&lt;\/title&gt;\r\n    &lt;meta charset='utf8'&gt;\r\n    &lt;link rel=\"import\" href=\"import.html\"&gt;\r\n    &lt;style&gt;\r\n        .content{\r\n            margin: 20px;padding: 15px;\r\n            width: 300px;height: 400px;\r\n            border: 1px solid #ccc;border-radius: 5px;\r\n            box-shadow: 0 0 10px #009933 inset;\r\n            overflow: auto;\r\n        }\r\n        .btn{\r\n            width: 120px;line-height: 30px;\r\n            font-size: 16px;\r\n            text-align: center;\r\n            padding: 10px 15px;\r\n            border-radius: 5px;\r\n            border: 1px solid #ccc;\r\n            box-shadow: 0 0 5px #ddd;\r\n        }\r\n        .btn:focus{\r\n            outline: none;\r\n            box-shadow: 0 0 10px green;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;div class=\"content\"&gt;\r\n    &lt;\/div&gt;\r\n    &lt;p class=\"tmpl\"&gt;&lt;\/p&gt;\r\n    &lt;p&gt;\r\n        &lt;button class=\"btn add\"&gt;\u6dfb\u52a0&lt;\/button&gt;\r\n    &lt;\/p&gt;\r\n    &lt;template id=\"tmpl1\"&gt;\r\n        &lt;h1&gt;hello feenan!&lt;\/h1&gt;\r\n    &lt;\/template&gt;\r\n    &lt;script src=\"\/lib\/jquery\/dist\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script&gt;\r\n        $('.add').click(function(){\r\n\r\n            var link = $('link[rel=import]')[0];\r\n\r\n            \/\/ \u83b7\u53d6\u5f15\u5165\u6587\u4ef6\u7684\u6a21\u677f\u5185\u5bb9,\u8fd4\u56de\u7684\u5176\u5b9e\u662f#document\u7c7b\u578b\r\n            var link_doc = link.import;\r\n\r\n            \/\/ \u521b\u5efashadow dom \u5143\u7d20,\u672c\u8d28\u662f\u4e00\u4e2adocumetn\u7247\u6bb5\u5143\u7d20\r\n            var shadowroot = $('.content')[0].createShadowRoot();\r\n\r\n            \/\/ \u521b\u5efa\u6837\u5f0f\r\n            var style = function(){\r\n                var css = document.createElement('style');\r\n                \/\/ \u901a\u8fc7styleSheets\u83b7\u53d6\u6a21\u677f\u5185\u7684\u6837\u5f0f\u5185\u5bb9\r\n                css.textContent = link_doc.styleSheets[0].rules[0].cssText;\r\n                return css;\r\n            }\r\n\r\n            \/\/ \u521b\u5efa\u5185\u5bb9\r\n            var body = function(){\r\n                return $(link_doc.body.innerHTML)[0];\r\n            }\r\n\r\n            shadowroot.appendChild(style());\r\n            shadowroot.appendChild(body());\r\n            $('.content').append($(link_doc).find('body').html());\r\n\r\n            \/\/ \u4f7f\u7528template\u6765\u83b7\u53d6\u6a21\u677f\u6587\u4ef6\r\n            $('.content').append($('#tmpl1')[0].content.cloneNode(true));\r\n\r\n        });\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<ul>\n<li>\u4ee5\u4e0a\u7684\u4f8b\u5b50\u5efa\u8bae\u5728<code>chrome 36<\/code>\u91cc\u8fd0\u884c<\/li>\n<\/ul>\n<h3 id=\"-\">\u603b\u7ed3<\/h3>\n<p>\u975e\u5e38\u9ad8\u5174<code>chrome36<\/code>\u7a33\u5b9a\u7248\u5df2\u5bf9<code>template,import,customer element,shadow dom<\/code>\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u652f\u6301,\u66f4\u591a\u5173\u4e8e\u5404\u4e2a\u6d4f\u89c8\u5668\u5bf9<code>web components<\/code>\u652f\u6301\u8bf7<\/p>\n<p>\u5173\u4e8e<code>web components<\/code>\u76f8\u5173\u7684\u7f51\u7ad9\uff0c\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u5730\u5740,\u5927\u90e8\u5206\u90fd\u8981\u7ffb\u5899\u6d4f\u89c8,\u56e0\u4e3a\u57fa\u672c\u4e0a\u90fd\u662f<code>google<\/code>\u7ef4\u62a4\u7684<\/p>\n<p>webcomponents \u5b98\u7f51<\/p>\n<p>Polymer \u6846\u67b6, google\u51fa\u54c1\u7684\u5f00\u53d1web\u7ec4\u4ef6\u7684\u6846\u67b6,\u517c\u5bb9\u5927\u90e8\u5206\u6d4f\u89c8\u5668<\/p>\n<p>w3c web \u7ec4\u4ef6\u89c4\u8303<\/p>\n<\/div>\n<div class=\"disclaimer\"><i class=\"fa fa-frown-o\"><\/i><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Web Components \u7684\u73b0\u72b6 \u5230\u76ee\u524d\u4e3a\u6b62,w3c\u5b9a\u4e49\u7684web components\u5df2\u7ecf\u5305\u542b\u4e86 Temp&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[8],"tags":[37,233,39],"_links":{"self":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/346"}],"collection":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/comments?post=346"}],"version-history":[{"count":2,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/346\/revisions"}],"predecessor-version":[{"id":348,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/346\/revisions\/348"}],"wp:attachment":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/media?parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/categories?post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/tags?post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}