Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

undefined is not a function #39

Open
jmls opened this issue Feb 4, 2015 · 18 comments
Open

undefined is not a function #39

jmls opened this issue Feb 4, 2015 · 18 comments

Comments

@jmls
Copy link

jmls commented Feb 4, 2015

thought I'd try the tutorials, but can't get past #1 :(

When I include webcomponents.js, I get this message

undefined is not a function (webcomponents.js:30)

line 30 is :
var parts = flags.log.split(",");

@arthurevans
Copy link
Contributor

Do you have any code before importing webcomponents? You shouldn't be seeing this unless you're setting WebComponents.flags.log.

(Also can you add your browser, browser version and OS?)

@jmls
Copy link
Author

jmls commented Feb 4, 2015

aww, I do. I am using angular ...
chrome Version 40.0.2214.91 (64-bit)
ubuntu 14.10
3.16.0-29-generic #39-Ubuntu SMP Mon Dec 15 22:27:29 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

hope this helps

@arthurevans
Copy link
Contributor

When you say, "I do" do you mean you have scripts before webcomponents.js? Or that you're setting WebComponents.flags.log?

And are you working through this Polymer tutorial (in which case Angular should not be involved) or are you doing a different tutorial?

@jmls
Copy link
Author

jmls commented Feb 4, 2015

Sorry for not being clearer. I have angular code after the webcomponents.js . I was using the tutorial for guidance on how to implement polymer (I wanted to use the ui from polymer in my angular app)

Are the two incompatible ?

@arthurevans
Copy link
Contributor

Gotcha. I know people have used Angular and Polymer together. I don't have any experience with it myself. You might take a look over here as a starting point:

https://gabiaxel.github.io/ng-polymer-elements/

(I haven't tested this, so YMMV, but might serve as a starting point for using Polymer with Angular.)

@AnothrNmbr
Copy link

I have the same problem (webcomponents.js line 30) but do not have any code before importing webcomponents.js. I am not explicitly setting WebComponents.flags.log. Running Win7 64-bit with chrome Version 40.0.2214.115 m. That said, my polymer components on page appear to be working fine.

@rdrey
Copy link

rdrey commented Feb 25, 2015

I got this because I was importing a non-existent (custom) polymer component. But my setup is pretty crazy (Meteor.js + differential:vulcanize + Polymer), so no idea whether that's your issue, too.

@s-a
Copy link

s-a commented Mar 7, 2015

Same problem here :( I am not using tutorials. I have installed webcomponents.js via bower.
Using
// @Version 0.5.5

The problem is that flags.log is type object instead of array. So there does not exists a method called split()

It seems that this is fixed at https://github.com/webcomponents/webcomponentsjs/blob/master/webcomponents.js#L37 but I can not see any version informations there. And I hope this is the correct repository ^^.

webcomponents/webcomponentsjs@bc7afc1 Fix error calling .split on undefined.

@robdodson
Copy link
Contributor

Looks like it's fixed but hasn't been released yet. @garlicnation is that
correct?

On Sat, Mar 7, 2015 at 12:30 AM, Stephan Ahlf [email protected]
wrote:

Same problem here :( I am not using tutorials. I have installed
webcomponents.js via bower.
Using
// @Version https://github.com/version 0.5.5

The problem is that flags.log is type object instead of array. So there
does not exists a method called split()

It seems that this is fixed at
https://github.com/webcomponents/webcomponentsjs/blob/master/webcomponents.js#L37
but I can not see any version informations there. And I hope this is the
correct repository ^^.

webcomponents/webcomponentsjs@bc7afc1
webcomponents/webcomponentsjs@bc7afc1
Fix error calling .split on undefined.


Reply to this email directly or view it on GitHub
#39 (comment)
.

@AnothrNmbr
Copy link

I got this error message to go away by pulling out the , , and tags as well as removing the <script> to include webcomponents.js from the polymer-element file for the custom tag i was creating. In the older example I was working from it seemed like a fully tagged html file was the way to go but in more recent examples i've only seen the polymer-element (with script and link tags) and no parent tags containing them.

@robdodson
Copy link
Contributor

@AnothrNmbr looks like your comment lost some pieces, which tags were you pulling out?

@AnothrNmbr
Copy link

oops, so my custom polymer-element file was a fully tagged html file with html, head, and body tags as well as its own script tag to reference webcomponents.js. I thought I saw this pattern in some example somewhere, but after looking again at more recent examples, the files defining polymer-elements never had these top level containers. after removing them and the reference to webcomponents.js (which is still referred to in the parent document), the error message went away.

@robdodson
Copy link
Contributor

the HTML Import you create for your polymer element should only need to reference polymer.html, it does not need to include webcomponents.js

ex:

<link rel="../components/polymer/polymer.html">

<polymer-element name="x-foo">
...
</polymer-element>

@AnothrNmbr
Copy link

ok got it. For some reason, this was no problem before I updated from 0.5.1 to 0.5.5. anyway, thanks for your help!

@garlicnation
Copy link

It's fixed at head. You can temporarily update your dependency to head, or wait until the next release(later today, pending some Spartan testing).

@andresfelipemendez
Copy link

same error, i have integrated polymer with meteor this is my main.html

<title>MyApp</title>
<link rel="shortcut icon" href="/resources/favicon.ico"/> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/components/webcomponentsjs/webcomponents.js"></script>
<link href='//fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>

the error:
webcomponents.js:30 Uncaught TypeError: undefined is not a function

@vertex
Copy link

vertex commented Mar 27, 2015

Also encountering this issue 👍

@s-a
Copy link

s-a commented Mar 28, 2015

Hello @ALL, I resolved this issue to my wrong usage. First of all you indeed need webcomponents.js. I guess it shims functionality for other Browsers than chrome. While chrome supports some things native other Browsers need this library. To resolve this issue you need to link the library before any HTML import. Here is my working example https://github.com/s-a/beatproducer/blob/81e1d24df76da8ac77200254bd0a916b8cc5a09e/public/index.html#L9

deltaidea added a commit to cyberFund/cyber.fund that referenced this issue Mar 29, 2015
…efore all the other stuff

The polyfill should be included before anything Polymer-related, otherwise it will cause problems.
It did cause a JS error: `undefined is not a function (webcomponents.js:30)`.
This commit fixes that issue.

More info: googlearchive/polymer-tutorial#39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants