The demo in the doc of Behaviors is broken

53 views
Skip to first unread message

NanoWANG

unread,
May 28, 2015, 6:15:00 AM5/28/15
to polym...@googlegroups.com
Hi all,

So in 0.9 Mixins becomes Behaviors, but I can't even make the official demo work.

As said in the doc, I should put the behavior object in a html file(which is weird since it'll broke some build chains), and then do this:

<link rel="import" href="highlight-behavior.html">

But all I got is `HighlightBehavior not defined` when runinng the line

behaviors: [HighlightBehavior]

On the other hand, I renamed the extension of the script to `.js` and tried this:
<script src="highlight-behavior.js">

<script>
  Polymer({
    is: 'my-element',
    behaviors: [HighlightBehavior]
  });
</script>

And it works fine.

So I'm wondering is that a bug in docs or am I doing something wrong?

Thx

NanoWANG

NanoWANG

unread,
May 28, 2015, 6:45:28 AM5/28/15
to polym...@googlegroups.com
Additionally, the only problem is, it will pollute the global environment, if using <script> instead of <link>

Justin Fagnani

unread,
May 28, 2015, 10:49:25 AM5/28/15
to NanoWANG, Arthur Evans, polymer-dev
+Arthur

You should still use a .html file and a <link> to import it, but the demo just leaves a <script> tag around the behavior definition.

And yes, the demo pollutes the global environment. Polymer does not prescribe a module system, but you can use one, like AMD (via the html import friendly IMD[1] package) if you like.

Cheers,
  Justin



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/39c9e7ea-8c1d-4785-925d-19ca997da7e2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

NanoWANG

unread,
May 28, 2015, 11:11:49 AM5/28/15
to polym...@googlegroups.com, nami...@gmail.com, art...@google.com
+Justin

Thanks!

I'll go create a PR for the doc.

Justin Fagnani

unread,
May 28, 2015, 11:12:47 AM5/28/15
to NanoWANG, Arthur Evans, polymer-dev
On Thu, May 28, 2015 at 7:49 AM, Justin Fagnani <justin...@google.com> wrote:
+Arthur

You should still use a .html file and a <link> to import it, but the demo just leaves a <script> tag around the behavior definition.

That should be "leaves out a <script> tag", that is make behavior definition an actual html file.

NanoWANG

unread,
May 28, 2015, 11:14:41 AM5/28/15
to polym...@googlegroups.com, nami...@gmail.com, art...@google.com
Totally know what you mean :)
Reply all
Reply to author
Forward
0 new messages