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

Inject template and tests #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Inject template and tests #3

wants to merge 7 commits into from

Conversation

wswoodruff
Copy link
Collaborator

No description provided.

@wswoodruff
Copy link
Collaborator Author

Test 4 is failing to prove there's an issue with this.$.* in base elements. Test 5 proposes a possible fix by doing a regex search and replace?

@wswoodruff
Copy link
Collaborator Author

Let's add a test for the CSS as well! Is that getting copied over just fine?

@devinivy
Copy link
Owner

Awesome start! Can we nix the console.logs?

@@ -55,6 +55,17 @@
behaviorDefinition[key] = thisPrototype[key];
}

behaviorDefinition.injectFrom = function(base, target) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be another method passed to _addFeature.

@@ -55,6 +55,17 @@
behaviorDefinition[key] = thisPrototype[key];
}

behaviorDefinition.injectFrom = function(base, target) {
var baseElement = document.createElement(base);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if base isn't an element that's being mixed in to the ext component? I suppose this function could care and enforce that, or it could work for any base element type. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of injectFrom is to be an accessory of .toBehavior and should only be used in a misbehaving element for the purpose of getting the inherited template. I think we should enforce that base be 'one of' the elements .toBehavior-ing in the ext component.

@devinivy
Copy link
Owner

Will this respect bindings? We need an injectBoundHTML() type of thing, don't we? Have you seen http://stackoverflow.com/questions/30836412/polymer-1-0-injectboundhtml-alternative ?

I'm not sure about how to deal with styles...

@wswoodruff
Copy link
Collaborator Author

loL that SO post is where I found the misbehavy fix for injecting HTML grabbed from an ajax call. <element inner-h-t-m-l="{{prop}}"></element>
Looks like it does have its issues but we aren't binding with anything passed in here for the project I needed it for.

As for styles... Let's just look for a <style> tag or <link> (with type 'css') in the base!

@wswoodruff
Copy link
Collaborator Author

There's an issue in my code with the code from 'another-component' executing once with all undefined props, etc. and a 2nd time with everything working fine.
On line 34 of 'another-component' I have to run a check to see if it exists before calling a function, otherwise we get an error.

@wswoodruff
Copy link
Collaborator Author

And I'm failing the 'preserves sub-behaviors' test still, I haven't tried to fix it, hoping for it to work itself out while merging this with your other things. The this.$.* tests pass though!!


// And baseTemplateInstance will only have a children array if it hasn't been added to the DOM yet!
var self = this;
Polymer.dom(baseTemplateInstance).children.forEach(function(child) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about children's children, etc.? Hopefully there's a way we can get Polymer to do this work. More info possibly here: https://github.com/Polymer/polymer/blob/b0733d3c07f071cb05ae88473cd07caee20ffe03/src/standard/annotations.html

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

Successfully merging this pull request may close these issues.

2 participants