Last active
March 8, 2016 01:30
-
-
Save jdanyow/995d61c259bd17f8ed97 to your computer and use it in GitHub Desktop.
This file contains 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="elem"></require> | |
<button click.delegate="show()">Show</button> | |
<elem if.bind="item.visible" item.bind="item"></elem> | |
</template> |
This file contains 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 { | |
item = { visible: true, name: 'apple' }; | |
show() { | |
this.item.visible = true; | |
} | |
} |
This file contains 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> | |
<div repeat.for="item of items"> | |
<button click.delegate="$parent.hide(item)">Hide</button> | |
${item.name} | |
</div> | |
</template> |
This file contains 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 { customElement, bindable } from 'aurelia-framework'; | |
// set this to true to "fix" the bug | |
const USE_NEXT_TICK = false; | |
@customElement('elem') | |
export class Elem { | |
@bindable item; | |
items; | |
itemChanged() { | |
this.items = [this.item]; | |
} | |
hide(item) { | |
this.items = [this.item]; | |
if (USE_NEXT_TICK) { | |
setTimeout(() => { item.visible = false; }, 0); | |
} else { | |
item.visible = false; | |
} | |
} | |
} |
This file contains 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"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
This file contains 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 {If} from 'aurelia-templating-resources'; | |
If.prototype.valueChanged = function(newValue) { | |
if (!newValue) { | |
if (this.view !== null && this.showing) { | |
//this.taskQueue.queueMicroTask(() => { | |
let viewOrPromise = this.viewSlot.remove(this.view); | |
if (viewOrPromise instanceof Promise) { | |
viewOrPromise.then(() => this.view.unbind()); | |
} else { | |
this.view.unbind(); | |
} | |
//}); | |
} | |
this.showing = false; | |
return; | |
} | |
if (this.view === null) { | |
this.view = this.viewFactory.create(); | |
} | |
if (!this.view.isBound) { | |
this.view.bind(this.bindingContext, this.overrideContext); | |
} | |
if (!this.showing) { | |
this.showing = true; | |
this.viewSlot.add(this.view); | |
} | |
} | |
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging(); | |
aurelia.start().then(() => aurelia.setRoot()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment