Skip to content

Commit

Permalink
feat(custom-element): add beforeCompile hook
Browse files Browse the repository at this point in the history
If you need to process the view’s template before it is compiled, you
can now add a beforeCompile static method to your custom element class.

Fixes #9
  • Loading branch information
EisenbergEffect committed Feb 5, 2015
1 parent 1fa4ca9 commit a7d34b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export class CustomElement extends ResourceType {
var options;

viewStrategy = viewStrategy || ViewStrategy.getDefault(target);
options = { targetShadowDOM:this.targetShadowDOM };
options = {
targetShadowDOM:this.targetShadowDOM,
beforeCompile:target.beforeCompile
};

if(!viewStrategy.moduleId){
viewStrategy.moduleId = Origin.get(target).moduleId;
Expand Down
4 changes: 4 additions & 0 deletions src/view-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export class ViewCompiler {

targetShadowDOM = targetShadowDOM && hasShadowDOM;

if(options.beforeCompile){
options.beforeCompile(templateOrFragment);
}

if(templateOrFragment.content){
content = document.adoptNode(templateOrFragment.content, true);
}else{
Expand Down

0 comments on commit a7d34b5

Please sign in to comment.