custom-element

Composing v1 nested web components

≯℡__Kan透↙ 提交于 2019-11-27 03:29:49
问题 I'm new to webcomponents. Since v1 of webcomponents is available, I'm starting there. I have read various posts around the web about them. I'm particularly interested in composing them correctly. I have read about slots and have them working, although my efforts have not resulted in slotted webcomponents that work the way I expected. If I have compose nested web components like this, the DOM from the nested/slotted webcomponent does not get inserted in the slot of the parent: <parent

How to let imported css have effects on elements in the shadow dom?

耗尽温柔 提交于 2019-11-27 02:11:36
Say if I want to create a custom element using shadow dom. Some elements in the template have class names specified in the linked css file. Now I want to let the css rules have effects on the elements. But I can't achieve that because of the shadow dom style boundary. <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> <template id="blog-header"> <header> <h1>DreamLine</h1> <nav> <ul> <li><a href="#0">Tour</a></li> <li><a href="#0">Blog</a></li> <li><a href="#0">Contact</a></li> <li><a href="#0">Error</a></li> <li><a href="

Click event not firing when React Component in a Shadow DOM

情到浓时终转凉″ 提交于 2019-11-27 01:33:55
问题 I have a special case where I need to encapsulate a React Component with a Web Component. The setup seems very straight forward. Here is the React Code: // React Component class Box extends React.Component { handleClick() { alert("Click Works"); } render() { return ( <div style={{background:'red', margin: 10, width: 200, cursor: 'pointer'}} onClick={e => this.handleClick(e)}> {this.props.label} <br /> CLICK ME </div> ); } }; // Render React directly ReactDOM.render( <Box label="React Direct"

Vanilla web-component structure

大城市里の小女人 提交于 2019-11-26 23:25:15
问题 I am looking into structuring vanilla web-components. I have previously used Polymer and like the fact that you can have the template, styles and JavaScript in one file for your component. I want to achieve this with 'vanilla' web components if possible but can't work out how. I've taken the code from here and added it to a file which I am using as follows: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1">

How to let imported css have effects on elements in the shadow dom?

心不动则不痛 提交于 2019-11-26 09:59:35
问题 Say if I want to create a custom element using shadow dom. Some elements in the template have class names specified in the linked css file. Now I want to let the css rules have effects on the elements. But I can\'t achieve that because of the shadow dom style boundary. <link rel=\"stylesheet\" type=\"text/css\" href=\"https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css\"> <template id=\"blog-header\"> <header> <h1>DreamLine</h1> <nav> <ul> <li><a href=\"#0\">Tour</a><

How to create new instance of an extended class of custom elements

谁都会走 提交于 2019-11-26 08:33:07
问题 I\'m trying the example from google developer site and I\'m getting Error: \"TypeError: Illegal constructor. What\'s wrong and How to fix it? class FancyButton extends HTMLButtonElement { constructor() { super(); // always call super() first in the ctor. this.addEventListener(\'click\', e => this.drawRipple(e.offsetX,e.offsetY)); } // Material design ripple animation. drawRipple(x, y) { let div = document.createElement(\'div\'); div.classList.add(\'ripple\'); this.appendChild(div); // div

Are custom elements valid HTML5?

隐身守侯 提交于 2019-11-26 01:27:12
问题 I\'ve been unable to find a definitive answer to whether custom tags are valid in HTML5, like this: <greeting>Hello!</greeting> I\'ve found nothing in the spec one way or the other: http://dev.w3.org/html5/spec/single-page.html And custom tags don\'t seem to validate with the W3C validator. 回答1: The Custom Elements specification is available in Chrome and Opera, and becoming available in other browsers. It provides a means to register custom elements in a formal manner. Custom elements are