Injecting classes into Polymer and having double brace bindings work...

40 views
Skip to first unread message

sams...@gmail.com

unread,
Jun 20, 2015, 1:04:51 AM6/20/15
to polym...@googlegroups.com
I'm working on creating Selenium tests for a very large Polymer webapp.

The developers would prefer that I don't modify the actual app.

So instead I'm trying to inject the extra pieces I need to make this easier using Javascript.  I then want to inject this Javacript into the app using Selenium, before running the actual test.

But so far, I'm just trying things in the console to see what works.

So, for example, I want to add a dynamic class to this for example:

<span id="value" class="io-editor" tabindex="0" spellcheck="false" contenteditable></span>

If I actually go into the html, and add qasel_io-number_{{value}} as so:

<span id="value" class="io-editor qasel_io-number_{{value}}" tabindex="0" spellcheck="false" contenteditable></span>

And I have for example the value of 7, I get the expected result of a class named qasel_io-number_7

But I can't figure out how to do this dynamically after the fact.

Now I've tried a bunch of different ways to do this in javascript, both with and without using JQuery.  

Here's an example of just one of the ways I've tried it. 

$("body /deep/ .io-editor").addClass("qasel_io-number_{{value}}")

(I've also tried variations of this using Polymer's $$, also to no avail).

The classes get added, but the double brackets and value are inserted literally, instead of being "magical" properties.

How can I make {{value}} update automatically?

Thanks!


ock...@gmail.com

unread,
Jun 20, 2015, 1:13:25 AM6/20/15
to polym...@googlegroups.com
Oh, I should probably add that the app is using version 0.5.5 of Polymer, just in case that matters.

And at least for now, it's okay if the solution works only in Chrome/Chromium (although something cross browser would of course be even better).

Max

unread,
Jun 20, 2015, 6:33:59 AM6/20/15
to ock...@gmail.com, polym...@googlegroups.com
I'm not sure about just classes, but it seems like injectBoundHTML might be useful?

Max.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/94b2f6fc-4732-4959-98c5-e4d89e724336%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages