web-component

How can I unit test a custom element

爱⌒轻易说出口 提交于 2021-01-28 10:10:11
问题 I have a class that extends HTMLElement . From reading this thread https://github.com/Microsoft/TypeScript/issues/574#issuecomment-231683089 I see that I can't instantiate a custom element with out getting a Illegal constructor . Additionally, the registerElement looked promising as it returned the constructor for the custom element but that is now deprecated for using CustomElementRegistry.define() that 1. exists on the window object and 2. returns void. Any solutions will be greatly

How can I unit test a custom element

旧巷老猫 提交于 2021-01-28 10:02:48
问题 I have a class that extends HTMLElement . From reading this thread https://github.com/Microsoft/TypeScript/issues/574#issuecomment-231683089 I see that I can't instantiate a custom element with out getting a Illegal constructor . Additionally, the registerElement looked promising as it returned the constructor for the custom element but that is now deprecated for using CustomElementRegistry.define() that 1. exists on the window object and 2. returns void. Any solutions will be greatly

How to re render table component upon receiving a notification from web socket in React JS?

大憨熊 提交于 2021-01-27 17:43:26
问题 Im using React table and loading a page which displays a table with data fetched from an API. Im also listening on a web socket and right now, whenever something is sent over a web socket, Im printing a console message. Now I want to reload the table(in turn making the API call) when I receive any update on the web socket. class TableExp extends React.Component { constructor() { super(); this.state = { tableData: [ { resourceID: '', resourceType: '', tenantName: '', dealerID: '', status: '',

Web components: How to work with children?

谁都会走 提交于 2020-12-29 05:41:31
问题 I'm currently experimenting with StencilJS to create some web components. Now I know that there is <slot /> and named slots and all that stuff. Coming from React, I guess slot is similar to children in React. You can do a lot of stuff using children in React. Things I often did: Check if any children are provided Iterate over children to do something to each child (e.g. wrap it in a div with a class etc.) How would you do that using slot/web components/stencilJS? I can get the Host Element of

Web components: How to work with children?

自古美人都是妖i 提交于 2020-12-29 05:40:28
问题 I'm currently experimenting with StencilJS to create some web components. Now I know that there is <slot /> and named slots and all that stuff. Coming from React, I guess slot is similar to children in React. You can do a lot of stuff using children in React. Things I often did: Check if any children are provided Iterate over children to do something to each child (e.g. wrap it in a div with a class etc.) How would you do that using slot/web components/stencilJS? I can get the Host Element of

Web components: How to work with children?

你离开我真会死。 提交于 2020-12-29 05:40:13
问题 I'm currently experimenting with StencilJS to create some web components. Now I know that there is <slot /> and named slots and all that stuff. Coming from React, I guess slot is similar to children in React. You can do a lot of stuff using children in React. Things I often did: Check if any children are provided Iterate over children to do something to each child (e.g. wrap it in a div with a class etc.) How would you do that using slot/web components/stencilJS? I can get the Host Element of

Styling not applied to vue web component during development

寵の児 提交于 2020-12-27 08:33:36
问题 While developing a Vue web component, the style is not applied to the web component, but added to the head of the document. This means that the style is ignored in the shadow DOM. Here is how I wrap the web component in main.js: import Vue from 'vue'; import wrap from '@vue/web-component-wrapper'; import MyWebComponent from './components/MyWebComponent'; const WrappedElement = wrap(Vue, MyWebComponent); window.customElements.define('my-web-component', WrappedElement); Again, any CSS rules

Using multiple angular elements as web components within an angular project

馋奶兔 提交于 2020-12-06 04:45:10
问题 Given three @angular projects all using v6.1.9: host , alpha , and beta alpha and beta create and define a web component each using @angular/elements as such: constructor(private injector: Injector) {} ngDoBootstrap() { const config: NgElementConfig = { injector: this.injector }; const component= createCustomElement(component, config); customElements.define("alpha-component", component); // beta-component respectively } alpha and beta are built using ng build --prod --output-hashing none and