custom-element | base class for Web Components | Web Framework library

 by   DannyMoerkerke JavaScript Version: Current License: Non-SPDX

kandi X-RAY | custom-element Summary

kandi X-RAY | custom-element Summary

custom-element is a JavaScript library typically used in Server, Web Framework, React applications. custom-element has no bugs, it has no vulnerabilities and it has low support. However custom-element has a Non-SPDX License. You can install using 'npm i @dannymoerkerke/custom-element' or download it from GitHub, npm.

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

            kandi-support Support

              custom-element has a low active ecosystem.
              It has 60 star(s) with 7 fork(s). There are 6 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 2 open issues and 0 have been closed. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of custom-element is current.

            kandi-Quality Quality

              custom-element has 0 bugs and 0 code smells.

            kandi-Security Security

              custom-element has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              custom-element code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              custom-element has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              custom-element releases are not available. You will need to build from source code and install.
              Deployable package is available in npm.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of custom-element
            Get all kandi verified functions for this library.

            custom-element Key Features

            No Key Features are available at this moment for custom-element.

            custom-element Examples and Code Snippets

            No Code Snippets are available at this moment for custom-element.

            Community Discussions

            QUESTION

            `Uncaught TypeError: Illegal constructor.` when extending HTMLSpanElement
            Asked 2022-Apr-17 at 19:21

            I am getting an Uncaught TypeError: Illegal constructor. for a basically empty constructor:

            ...

            ANSWER

            Answered 2022-Apr-17 at 19:21

            There 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)

            General advice

            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.

            Update

            Dont use the 3rd parameter for Autonomous Elements (extending HTMLElement)

            You can't mix settings:

            Source https://stackoverflow.com/questions/71901055

            QUESTION

            Referencing the host element in Vue v3 Custom Element components
            Asked 2022-Mar-29 at 09:37

            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:

            1. Are internally complex enough that building with Vue rather than just native web components is helpful, but...
            2. Will run outside Vue context on the page (not in a Vue app), so are packaged as Web Components / Custom Elements from Vue, and...
            3. 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:37

            Agree 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:

            Source https://stackoverflow.com/questions/71297767

            QUESTION

            Exposing functions on a Vue-defined Web Component (Custom Element)
            Asked 2022-Mar-04 at 10:12

            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:12

            For 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:

            Source https://stackoverflow.com/questions/71331974

            QUESTION

            Why are some of the secondary options not working for the rules in my .stylelintrc?
            Asked 2022-Mar-03 at 23:38

            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:45

            You are using the secondary option correctly as this demo shows:

            Source https://stackoverflow.com/questions/71098441

            QUESTION

            Can the CSS :part pseudo-selector be used to style nested web components?
            Asked 2022-Feb-10 at 04:09

            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:09

            Nope. 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:

            Source https://stackoverflow.com/questions/71047699

            QUESTION

            Hierarchical stacked element using JointJS
            Asked 2022-Jan-30 at 09:46

            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:46

            My 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/

            Source https://stackoverflow.com/questions/70909515

            QUESTION

            StencilJS error with React output target - You may need an additional loader to handle the result of these loaders
            Asked 2022-Jan-10 at 08:42

            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:42

            I 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

            Source https://stackoverflow.com/questions/70520813

            QUESTION

            leaflet usage in Preact JS
            Asked 2022-Jan-07 at 10:48

            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:48

            This 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).

            Source https://stackoverflow.com/questions/70578136

            QUESTION

            Angular web components with custom elements error
            Asked 2021-Dec-24 at 09:52

            I am trying to create a basic web component in Angular with Angular Elements.

            So far, I have done the following:

            1. Installed Elements using npm i @angular/elements --save
            2. Installed npm i @webcomponents/custom-elements -- save
            3. Added CUSTOM_ELEMENTS_SCHEMA to schemas array in app.module.ts
            4. Created the component, call it MyComponent
            5. Defined MyComponent as a custom element in AppModule using the code below
            ...

            ANSWER

            Answered 2021-Dec-23 at 16:23

            You may need to put your component in the entryComponents section.

            Source https://stackoverflow.com/questions/70461977

            QUESTION

            Cannot find module '@vaadin/flow-frontend/Flow'
            Asked 2021-Dec-22 at 23:53

            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:42

            I 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.

            Source https://stackoverflow.com/questions/70453756

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install custom-element

            You can install using 'npm i @dannymoerkerke/custom-element' or download it from GitHub, npm.

            Support

            Chrome 53+Firefox 63+Safari 10+iOS Safari 10+Chrome Android 71+Firefox Android 64+
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/DannyMoerkerke/custom-element.git

          • CLI

            gh repo clone DannyMoerkerke/custom-element

          • sshUrl

            git@github.com:DannyMoerkerke/custom-element.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Web Framework Libraries

            angular

            by angular

            flask

            by pallets

            gin

            by gin-gonic

            php-src

            by php

            symfony

            by symfony

            Try Top Libraries by DannyMoerkerke

            instant-multi-page-app

            by DannyMoerkerkeHTML

            material-webcomponents

            by DannyMoerkerkeJavaScript

            sw-proxy

            by DannyMoerkerkeJavaScript

            lazy-img

            by DannyMoerkerkeJavaScript

            swopr

            by DannyMoerkerkeJavaScript