Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.8] Undefined method in constructor #1207

Closed
robdodson opened this issue Feb 20, 2015 · 3 comments
Closed

[0.8] Undefined method in constructor #1207

robdodson opened this issue Feb 20, 2015 · 3 comments
Assignees
Labels

Comments

@robdodson
Copy link
Contributor

Given this sample element:

var XBaz = Polymer({

  is: 'x-baz',

  constructor: function(name) {
    var el = document.createElement(this.is);
    el.name = name;
    el.createTextContent(el.name);
    return el;
  },

  createTextContent: function(name) {
    this.textContent = 'Hello, from ' + name;
  }

});

var el = new XBaz('x-baz');
document.body.appendChild(el);

I get an error saying createTextContent is an undefined function.

@peterwmwong
Copy link
Contributor

@robdodson I think this is the same as #1151. I do have a PR for this #1152, which does seem to fix your testcase above: http://jsbin.com/nitedo/5/edit?html,output

@kevinpschaaf
Copy link
Member

Fixed in 24a2914 (didn't take PR #1152 as the implementation has changed a bit). Note the API change, such that the custom constructor need not call document.createElement and return the element. This will be done automatically; the user constructor should only configure the instance (this).

@kevinpschaaf
Copy link
Member

New API looks like this: http://jsbin.com/nijiyohoqa/2/edit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants