polymer

polymer: using a function in a data binding expression

陌路散爱 提交于 2019-12-11 02:54:30
问题 One of the properties of my Polymer element is a timestamp: Polymer({ timestamp: null, ready: function () { this.timestamp = new Date().getTime(); } }); In my markup I need to show a formatted timestamp: <template> timestamp={{getFormattedTimestamp()}} </template> where getFormattedTimestamp: function () { return new Date(this.timestamp).toLocaleString('en-US', {timeZoneName: 'short'}); } But the code above does not update the display when this.timestamp changes because Polymer does not know

Polymer use function validation on core-input

怎甘沉沦 提交于 2019-12-11 02:43:58
问题 Can someone explain me how to use the function validation of this Polymer element (navigate to the "validate" section? <core-input ... validate="test()" error="error in the input"></test> Here is definition of test: function test() { return true; } This way I always get some error message about: "error in the inout". How can I make this thing work? 回答1: As a security precaution, Polymer in general doesn't accept JavaScript in attributes. So, core-input doesn't accept validate="test()" syntax.

domReady vs ready - Migrating to Polymer 1.0

坚强是说给别人听的谎言 提交于 2019-12-11 02:43:25
问题 In Polymer0.5, I had the following code: Template: <div class="scroll"> <div class="content"> <content></content> </div> </div> Script: domReady: function() { var width = $(this.shadowRoot).find('.content')[0].scrollWidth; } This code worked, and I received a non-zero value for the width. Now I am trying to migrate to Polymer1.0, I added an ID to the div: <div class="scroll"> <div id="content" class="content"> <content></content> </div> </div> And the script is now: ready: function() { var

there doesn't seem to be a polymer-layout event

二次信任 提交于 2019-12-11 02:35:09
问题 I'm looking for an event fired by polymer-layout when it's finished laying out, similar to the polymer-grid-layout event. Doesn't seem to be one. Am I missing something? After my attempts at polymer-grid-layout (Autosizing canvas inside a polymer grid layout) I've decided to convert everything to nested polymer-layouts instead. After a few hiccups ( e.g. the dart version of polymer-layout doesn't work if you put polymer-layout as an element directly under template, whereas the js version does

Theme css selectors with React JS/Polymer

可紊 提交于 2019-12-11 02:29:04
问题 I'm working with a project that uses ReactJS and I'd like to modify the theme. I'm running into an issue writing the css selectors for my theme styles. It looks like reactjs uses some shadow dom which breaks css selectors across components. It looks like polymer uses shadow dom which breaks css selectors across components (by design). <div id="root" class="light-theme"> <style> .light-theme .bg-theme { background-color: white; } </style> <parent-element> <child-element class="bg-theme"> <

JayData : how to migrate code from v1.3 to v1.5

余生颓废 提交于 2019-12-11 02:06:13
问题 I have some code which worked in JayData 1.3. I need to upgrade JayData to 1.5 due to the compatibility issues the 1.3 version has with polymer. The upgrade instructions say you can use the " jaydata-compatibility.js " script to "upgrade your app to JayData 1.5.x from previous versions step-by-step", however when I add that in as described I simply get the error, " typeOrName requires a value other than undefined or null ", which actually doesn't help me step through the upgrade at all. Here

Missing <component>.html_script_0.js files in Polymer build using the CLI tool

£可爱£侵袭症+ 提交于 2019-12-11 01:40:36
问题 I'm having problems running the polymer build command of the polymer CLI, it gives me the following feedback: and neither of my built folders (bundled or unbundled) have the javascript files. The build process places <script> tag with the src of a javascript file in the place of my javascript code, but this files are not being generated. I don't know if both errors are related, but I don't know what can I do to generate the <component>.html_script_0.js files. 回答1: I had this same problem and

Polymer: Reload Styles when loading dynamic content

℡╲_俬逩灬. 提交于 2019-12-11 01:35:12
问题 I'm including styles using <style include="style-name"></style> which generally works fine. However, I have one element which dynamically loads and changes its contents via JavaScript. It will at some point load new content from some external source and update its contents accordingly. Those new contents do not have the style from style-name applied to them. How do I get Polymer to reevaluate the styles and therefore also apply them to the new content? I'm using Meteor + Synthesis if that

Listening to a polymer attached event from outside that element

荒凉一梦 提交于 2019-12-11 01:26:29
问题 In my team we are trying to write some unit tests for polymer custom elements. Most of our custom elements uses Polymer's template binding feature so we have lots of code written under attached callback of a custom element. When writing unit tests for these elements I can only listen to polymer-ready event but what we need is to run our test suite only after the polymer-attached event so the binding has already been complete. Right now we have done a dirty checking for the element we want to

Plain Javascript code that does what querySelector() and querySelectorAll() does, include shadowroots

对着背影说爱祢 提交于 2019-12-11 01:08:59
问题 I am trying to write a method that takes in two params: one of the parentNode of the current element where many childNodes with shadowroots within it, the second param being the id of an element within one of the shadowroots of one of the childNodes of this parentNode param. I tried to use the generic querySelector() methods that JS come with to find the element using the id alone, but it wouldn't work due to my element tags being inside the shadowroot. Due to this reason, I had write code