How to load a Polymer element after an event occurs? - polymer

For instance, a user logs in (dynamically, no page refresh) and only then do I want to load up my polymer elements.

You can load polymer elements dynamicaly using Polymer.import(['myElement.html']) function. More on: Polymer helper methods

also you could use the app router element that allows you to use the hash in the URL lo just import the number of elements you are going to use, or even it can load all of them and just charge if the hash is the correct one
look at https://github.com/erikringsmuth/app-router

Related

Simple way to find html-element which has been rendered by React

For fast searching elements by Selenium, I think it must be a simple way to set some attributes to html-elements, for example: transform React Component Key to data-attribute (if it is possible).
Of course I can writing id or data-attributes to my span, div and whatever in my components, but I can't do it with components of 3d-party libraries - this components may haven't props like "id", and I will have to wrap this components and then find they by tag or class...
Or maybe is plugin for webpack to set data-attributes to elements with component's names.
However, how you find elements in your react app render?
I think it's not a good idea find elements by class or tags
key transform like this:
<MyComponent key="SuperComponent" />
...
<div data-attr="SuperComponent">...</div>
or autoset attributes of component name like this:
<MySuperComponent />
...
<div data-attr="MySuperComponent">...</div>
From "Test Automation through Selenium" perspective it hardly matters if the HTML consists of id or data-attributes. While working with Selenium tests are written with the help of any effective <tag> and the associated attributes. However there is a preferred list of Locator Strategies as follows:
How to find elements in react app render?
The AUT (Application Under Test) being ReactJS based of-coarse the element will be having dynamic attributes. Locator Strategies can also be dynamic. You can find an example usage of Dynamic Locator Strategies in the discussion How to locate a button with a dynamicID
Finally, while Test Automation the fast moving WebDriver instance will be needed to be synchronized with the lagging browser. You can find a relevant discussion in Do we have any generic funtion to check if page has completely loaded in Selenium

AngularDart - Manipulate DOM from Component

so I am using the standard template from AngularDart that comes from stagehand web-angular-simple.
Now, if I have something hardcoded in index.html and try to manipulate it from main.dart using querySelector, everything works fine.
But how can I use querySelector to manipulate the AppComponent that was loaded into the index.html file in the template?
So basically my question is: how to manipulate dynamically loaded elements in dart.
(p.s. I just started out in AngularDart...)
thanks in advance
You can inject ElementRef and through it access nativeElement - this will be the DOM node of you component.
The question is why do you need? Almost always there is a way to do what you need through interacting with angular templates.

Separate CSS file for each angular2 component affects performance of page?

All the guides about Angular2 propose to have a separate file for css styling for each component. As I get is so far, for each custom directive there is the need to make requests to the server to get the html and css for that directive (component). If this is the case, what is the performance impact for the page when multiple requests are made for multiple directives? Is there any other recommended way?
That's only true during development. A build step (currently work in progress) will inline resources and generate code for declarative bindings. In the end there will be only a minimum number of requests.
Some related issues:
https://github.com/angular/angular/issues/8717
https://github.com/angular/angular/issues/8550
https://github.com/angular/angular/issues/8759
https://github.com/angular/angular/pull/8097
https://github.com/angular/angular/issues/6612#issuecomment-175894674
https://github.com/angular/angular/pull/8400

angularjs directive isolated scope within link method

My jsbin is here: http://jsbin.com/yapi/1/edit
I am testing the isolated scope within link method of the directive (it works when used within template instead).
My goal is that link method in different directives to be able to share and change same data (by reference, not by value). So that if a link method in one directive changes the data then it gets reflected in link method in other directives.
However, it does not seem to work as you can see in the jsbin link. e.g. if you change Dir 1 it does not change Dir 2 and vice versa.
i would use Angular's pub/sub pattern
Here is an article the talks about best practices
I would have a bunch of directives that interact with there own scope data,
when data changes in a directive it can $broadcast('message', data) a change to that data
other directives can listen $on('message', function(data){})
If you want everything to rely on the same data, then just use a service (singleton) that all the directive interact with

Why does Wicket changes the id of the html elements?

If I write
<form wicket:id="form" id="form>
or even
<form wicket:id="form>...
Then the rendered HTML shows the id 'form' appended with different numbers whenever the page is refreshed e.g.
<form id="form7"....
Is there a way to disable this behavior of the Wicket framework?
We set markup ids by hand extensively on our project to ease automatic testing with Selenium testing framework. It definitely works.
Component.setOutputMarkupId(true); // write id attribute of element to html
Component.setMarkupId("someid"); // id attribute of element is "someid"
This is the behavior you want in most cases when using wicket. The dynamic id is meant to prevent id collisions when Ajax behaviors are added to components or added to ajax responses for refreshing. For any of these situations, you really need both the client response and the server side state to be in cahoots. If there are external js resources you need the id of a component for dom lookup, then I would suggest adding a custom wicket component behavior that would then generate the js call to a function passing in the generated id.
I realize what I'm going to describe leads you more into the forest of Wicket. But I have been more than happy with the ajaxy stuff that Wicket opens up for you out of the box.
This is Wicket desing feature. You can use class for linking styles and components.
<form wicket:id="form" id="form>
Also you can to try (I never did it) setMarkupId . I'm not sure that it good way.
It has been a while since I worked with Wicket, but I remember that when wicket uses ajax elements, its ids are auto-generated (the id of the tag, not the wicket:id). You can control the id of the tag when not using and ajax element. In your case, since there is no code, I would guess that you will have to change any AjaxButton or Ajax* from your form.
Yes you can write custom JavaScript... you just need to implement it according to the 'Wicket way'. You can decorate components, Ajax calls etc. with custom JavaScript, then it all plays nicely.