custom-element | base class for Web Components | Web Framework library
kandi X-RAY | custom-element Summary
kandi X-RAY | custom-element Summary
A base class for Custom Elements which provides simple data binding. This is a simple POC to demonstrate how data binding can be easily implemented using Web Components. It is not a replacement for React or other frameworks, nor is it intended to be. See my article on medium.com for an in depth explanation.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of custom-element
custom-element Key Features
custom-element Examples and Code Snippets
Community Discussions
Trending Discussions on custom-element
QUESTION
I am getting an Uncaught TypeError: Illegal constructor.
for a basically empty constructor:
ANSWER
Answered 2022-Apr-17 at 19:21There are 2 types of Custom Elements MDN: Using Custom Elements
Autonomous Custom Elements:
extend HTMLElement
Customized Built-In Elements
Polyfill required for Safari
because Apple doesn't want to implement this type of elements.
For a good reason; read the very long debate (going back to 2016)
Stick to autonomous elements, unles you know what you are doing.
One registry to rule them all
(for now) There is only one registry so your Customized element is registered as fancy-button
;
That means you can not mix the 2 types, with the same element name.
Dont use the 3rd parameter for Autonomous Elements (extending HTMLElement)
You can't mix settings:
QUESTION
OK so I know a few variations on this question have been asked already, across the various versions and APIs of Vue... But I haven't been able to figure it out so here's the context as to why I think mine is different:
I'm trying to build some components which:
- Are internally complex enough that building with Vue rather than just native web components is helpful, but...
- Will run outside Vue context on the page (not in a Vue app), so are packaged as Web Components / Custom Elements from Vue, and...
- Implement data inputs that will be used inside
s (again, not in Vue apps).
One challenge with this is that Vue Web Components use shadow DOM, and forms don't automatically traverse shadow roots to look for inputs: So making the form actually see and submit the components' inner data is not automatic.
It seems like there's some hope as detailed in this helpful blog post: A new ElementInternals API and element-internals-polyfill NPM package by which components can indicate data up to forms. Implementing a "form-associated custom element" requires setting a static readonly boolean property (easy enough) but also linking something like:
...ANSWER
Answered 2022-Mar-29 at 09:37Agree this is a bad code smell and a signal to evaluate whether Vue is really a good fit for the use case in general: Hacking around with hybrid Web Components that aren't quite native but aren't quite Vue either is likely to be a maintenance burden even if it works today.
But needs must - and my current workaround for this is to track back from some reference element in the template (doesn't really matter what) via DOM, like this:
QUESTION
Per the Vue docs, it's possible to build components in Vue (v3) and package them as native Web Components for use with any framework or none at all.
As I've already found, the gap between design models for Vue components and Web Components can make this complex and sometimes a straight-up bad idea (at what point is it better and more maintainable to just go ahead building fully-native components?)... But let's assume for a moment that it's necessary here.
My question - What's the best way to expose a function-like interface on a Vue-built Web Component (to parent nodes)?
The Vue doc discusses passing in reactive data via props/slots, and publishing CustomEvents from the components, but I don't see mention of taking function calls (or at a stretch, events) from outside. As far as I can tell this is a pretty strong assumption that data and event flow on the rest of the app/page works in a very "Vue-like way"?
...ANSWER
Answered 2022-Mar-04 at 10:12For now, my workaround on this is to look up the host element in onMounted()
(as per this question) and just set whatever extra properties are required at that point (hoping they shouldn't be required before the Vue component mounts, because I'm not aware of any external events raised when Vue finishes mounting the custom element).
This way the function can still be defined in the context of, and access variables/etc from, the setup function - but can be called by other elements on the page that only have a reference to the element, not the Vue component.
Can't say I like it much though:
QUESTION
I am trying to format my css so there's no more than one empty line between lines, but i don't want that to apply to comments. The documentation for stylelint has a secondary option that should make this easy, but for some reason it isn't working. Here's the rule:
...ANSWER
Answered 2022-Feb-13 at 09:45You are using the secondary option correctly as this demo shows:
QUESTION
When creating Web Components with encapsulated styles using Shadow DOM, parts of the shadowed markup can be styled using the ::part pseudo selector (https://developer.mozilla.org/en-US/docs/Web/CSS/::part).
Can the part selector be used to target nested shadow parts?
...ANSWER
Answered 2022-Feb-10 at 04:09Nope. It is not possible. It kind a breaks the encapsulation principle. The right way is to use proper theming. That means using a combination of:
QUESTION
In JointJS documentation (link below), I am able to define a simple custom element that is driven from other basic elements such as Line, Rectangle, Link, and so on https://resources.jointjs.com/tutorial/custom-elements
What I am trying to accomplish is to create a Group (custom element) that consists of a label at the top, and then a number of compartments aligned vertically beneath that label. A compartment itself acts as a container, which can contain a complete sub diagram, which itself can have other Groups, and so on.
I get how to create the label, but I am struggling to find out how to create the compartments as per the description above. All examples I am able to find so far are for simple custom elements that add additional attributes to the extended base elements.
...ANSWER
Answered 2022-Jan-30 at 09:46My bad, I should have checked the documentation better. The link below explains the required. We need to embed elements of another root element.
https://resources.jointjs.com/tutorial/hierarchy
This snippet is also so helpful https://jsfiddle.net/kumilingus/xa1m5k2f/
QUESTION
I'm creating some basic elements in Stencil for a custom design system. I created some basic components, which work fine on their own as custom elements, but throw errors when used as React components.
I generated the React components via Stencil by includng the @stencil/react-output-target
in stencil.config.ts
.
ANSWER
Answered 2022-Jan-10 at 08:42I figured out what the issue. For some reason, the dist
folder was not being generated for me every time I ran npm run build
.
Sometimes it was generated, other times it wasn't. I believe it was due to some errors in my component code, which failed silently. So now I check for the dist folder every time I build the library.
In my final, working attempt I went with the monorepo approach as advised by the Stencil team in their documentation.
Here are all I took the steps for a basic Stencil library with a React output:
- Create a monorepo
- Create a Stencil Library
- Generate components using
npx stencil generate
- Update name in package.json to MY_LIBRARY
npm i @stencil/react-output-target
- Add the React Wrapper function to
stencil.config.ts
- Generate components using
QUESTION
How can we embeded leaflet Map into Preact component. I am creating a Map widget using webpack. In the below I show you the code I implemented.
...ANSWER
Answered 2022-Jan-07 at 10:48This is easy. I found a Stack Overflow question related to Leaflet usage in LitElement.
My answer is similar as this, but need to do some changes, because I am creating a web component (widget).
QUESTION
I am trying to create a basic web component in Angular with Angular Elements.
So far, I have done the following:
- Installed Elements using
npm i @angular/elements --save
- Installed
npm i @webcomponents/custom-elements -- save
- Added
CUSTOM_ELEMENTS_SCHEMA
toschemas
array in app.module.ts - Created the component, call it
MyComponent
- Defined
MyComponent
as a custom element inAppModule
using the code below
ANSWER
Answered 2021-Dec-23 at 16:23You may need to put your component in the entryComponents section.
QUESTION
Vaadin suddenly stops to build my library with the following error. I already did the Vaadin dance (and a lot of more stuff) but I'm running out of ideas now. I try to build the library for production (but it also fails for dev).
I'm using Vaadin Flow. The issue tracker on Github redirected here for general community help - so I hope anyone has an idea how to solve this problem or what else I can try.
...ANSWER
Answered 2021-Dec-22 at 19:42I had the same problem migrating from V21 to V22. I fixed it by deleting the target folder (and generated files in the root folder like tsconfig etc) and rebuilding again. Worked perfectly afterwards with no further problems. My suspicion was something stayed in the target folder from V21 and confused the build.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install custom-element
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page