Last active
          September 12, 2016 13:37 
        
      - 
      
- 
        Save mbroadst/2bd1a5b9c03e275a2ca13125853b94b9 to your computer and use it in GitHub Desktop. 
    Aurelia Templating Child/Children Bug
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <template> | |
| <require from="my-list"></require> | |
| <require from="my-list-element"></require> | |
| <my-list> | |
| <my-list-element>one</my-list-element> | |
| <my-list-element>two</my-list-element> | |
| <my-list-element>three</my-list-element> | |
| <my-list-element>four</my-list-element> | |
| <my-list-element>five</my-list-element> | |
| <my-list-element>six</my-list-element> | |
| <my-list-element>seven</my-list-element> | |
| <my-list-element>eight</my-list-element> | |
| <my-list-element>nine</my-list-element> | |
| <my-list-element>ten</my-list-element> | |
| <my-list-element>eleven</my-list-element> | |
| <my-list-element>twelve</my-list-element> | |
| <my-list-element>thirteen</my-list-element> | |
| <my-list-element>fourteen</my-list-element> | |
| </my-list> | |
| </template> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export class App { | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <!doctype html> | |
| <html> | |
| <head> | |
| <title>Aurelia</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> | |
| </head> | |
| <body aurelia-app="main"> | |
| <h1>Loading...</h1> | |
| <script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
| <script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
| <script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
| <script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
| <script> | |
| require(['aurelia-bootstrapper']); | |
| </script> | |
| </body> | |
| </html> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export function configure(aurelia) { | |
| aurelia.use | |
| .standardConfiguration() | |
| .developmentLogging(); | |
| aurelia.start().then(() => aurelia.setRoot()); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import {inject} from 'aurelia-dependency-injection'; | |
| import { | |
| bindable, | |
| customElement, | |
| noView, | |
| processContent, | |
| ViewCompiler | |
| } from 'aurelia-templating'; | |
| @noView | |
| @processContent(false) | |
| @customElement('my-list-element') | |
| @inject(Element, ViewCompiler) | |
| export class MyListElement { | |
| constructor(element, viewCompiler) { | |
| this.viewFactory = | |
| viewCompiler.compile(`<template>${element.innerHTML}</template>`); | |
| element.innerHTML = ''; | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <template> | |
| <slot></slot> | |
| </template> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { | |
| bindable, | |
| children, | |
| customElement, | |
| ViewCompiler, | |
| ViewSlot | |
| } from 'aurelia-templating'; | |
| import {inject, Container} from 'aurelia-dependency-injection'; | |
| import {ObserverLocator} from 'aurelia-binding'; | |
| import {AbstractRepeater, RepeatStrategyLocator} from 'aurelia-templating-resources'; | |
| @inject(Container, ViewSlot, ViewCompiler, ObserverLocator, RepeatStrategyLocator) | |
| export class MyList extends AbstractRepeater { | |
| @children('my-list-element') rows = []; | |
| constructor(container, viewSlot, viewCompiler, observerLocator, strategyLocator) { | |
| super({ | |
| local: 'row', | |
| viewsRequireLifecycle: false | |
| }); | |
| this.container = container; | |
| this.viewSlot = viewSlot; | |
| this.observerLocator = observerLocator; | |
| this.strategyLocator = strategyLocator; | |
| this.scope = null; | |
| this.strategy = null; | |
| this.rowViewFactory = | |
| viewCompiler.compile('<template><slot></slot></template>'); | |
| this.rowViewSlots = []; | |
| } | |
| attached() { | |
| console.log('children: ', this.rows); | |
| console.log('child count: ', this.rows.length); | |
| } | |
| // @override AbstractRepeater | |
| views() { return this.rowViewSlots; } | |
| view(index) { return this.rowViewSlots[index]; } | |
| viewCount() { return this.rowViewSlots.length; } | |
| addView(bindingContext, overrideContext) { | |
| console.log('addView(bctx= ', bindingContext, ')'); | |
| } | |
| insertView(index, bindingContext, overrideContext) { | |
| console.log('insertView(index=', index, ', bctx= ', bindingContext, ')'); | |
| } | |
| removeAllViews() { | |
| console.log('removeAllViews()'); | |
| } | |
| removeView(index) { | |
| console.log('removeView(index=', index, ')'); | |
| } | |
| updateBindings(view) { | |
| console.log('updateBindings(view=', view, ')'); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment