polymer-2.x

Best way to communicate between instances of the same web component with Polymer?

爷,独闯天下 提交于 2019-12-03 00:58:34
I'm trying to sync some of my web component properties between instances of the same element so if one of this properties changes then the same property gets updated in all the instances with the corresponding binding and events. Note: I want to use the Polymer Data System Concepts for the communications between instances. Example my-element.html <dom-module id="my-element"> <script> Polymer({ is: 'my-element', properties: { myProp: { type: String, notify: true } }); </script> </dom-module> my-other-element.html <dom-module id="my-other-element"> <template> <my-element my-prop="{{otherProp}}">

Does jQuery work well with Polymer 2?

旧城冷巷雨未停 提交于 2019-12-02 10:30:47
There are many mixed answers. But they're all answers from a few years ago and relating to Polymer 1. Thanks. It does work but it won´t work well. Have a look this . The only way jquery and polymer work well togehter is polymer 1 and shady dom but thats deprecated. The question can be interpreted in two ways - can legacy jquery code create polymer components/custom tags? The answer is YES . The other interpretation is - can I use jquery INSIDE my web components? The answer is "maybe, but its a really bad idea, don't do it" . 来源: https://stackoverflow.com/questions/45338428/does-jquery-work

Polymer DomModule already defined

懵懂的女人 提交于 2019-12-01 18:42:50
问题 I'm building a website, where I'd use different polymer components, some of them multiple times. My problem is that the compiled code contains a customElements.define('dom-module', DomModule); that throws Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry at CustomElementRegistry.value I have no idea how to resolve this. 回答1: If you include polymer using two different paths in two different components, both of them

How do I enable Shady DOM in Polymer 2.0?

Deadly 提交于 2019-11-30 13:54:19
Polymer 1.x uses Shady DOM by default, but that could be changed at initialization by setting the window.Polymer object before importing polymer.html as follows: <script>window.Polymer = {dom: 'shadow'};</script> <link rel="import" href="polymer.html"> However, it seems Polymer 2.0 uses Shadow DOM regardless of window.Polymer = {dom: 'shady'} . How do I switch to Shady DOM? The Shady DOM shim was factored out of Polymer in 2.0 and moved into the v1 Web Components polyfill. To enable Shady DOM (instead of the default Shadow DOM), define the following window.ShadyDOM object before importing the

Response for preflight 403 forbidden

隐身守侯 提交于 2019-11-29 16:33:36
I've been trying to make a simple iron-ajax post to the server, but it keeps failing at the preflight call. For the life of me I can't figure out what's going on, all the CORS headers seem to be correct on the server. Response headers Access-Control-Allow-Credentials:true Access-Control-Allow-Headers:Content-Type Access-Control-Allow-Methods:GET, POST, PUT, OPTIONS Access-Control-Allow-Origin:* cache-control:must-revalidate, private, no-cache, no-store, max-age=0 Connection:Keep-Alive Content-Encoding:gzip Content-Length:138 Content-Type:text/html Request headers Accept:*/* Accept-Encoding

Applying Behaviors with JS Mixins in Polymer 2

好久不见. 提交于 2019-11-29 09:23:16
问题 I want a custom element I'm defining to have the Polymer.IronScrollTargetBehavior in Polymer 2. In Polymer 1, this can be done by adding it to the behaviors array: Polymer({ is: 'my-element', behaviors: [Polymer.IronScrollTargetBehavior] }); In the Polymer 2 upgrade guide, it says that you should: Implement "behaviors" as mixins that return class expressions. In the linked article, it explains how you can use the following syntax for mixins: let MyMixin = (superclass) => class extends

Response for preflight 403 forbidden

泄露秘密 提交于 2019-11-28 10:57:10
问题 I've been trying to make a simple iron-ajax post to the server, but it keeps failing at the preflight call. For the life of me I can't figure out what's going on, all the CORS headers seem to be correct on the server. Response headers Access-Control-Allow-Credentials:true Access-Control-Allow-Headers:Content-Type Access-Control-Allow-Methods:GET, POST, PUT, OPTIONS Access-Control-Allow-Origin:* cache-control:must-revalidate, private, no-cache, no-store, max-age=0 Connection:Keep-Alive Content