-
-
Save rytmis/b31d1281caf4bddd4ddce2e47f0b993e to your computer and use it in GitHub Desktop.
InheritBindingContext breaks refs
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="./parent-element"></require> | |
<h1>${message}</h1> | |
<parent-element /> | |
</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 { | |
message = 'Hello World!'; | |
} |
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 ref="theRef">I am in a child element.</div> | |
<button click.delegate="show()">Display child ref content:</button> <span>${childRefContent}</span> | |
</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, processContent } from "aurelia-framework" | |
@customElement('child-element') | |
@processContent((_, __, ___, instruction) => { | |
instruction.inheritBindingContext = true; | |
return true; | |
}) | |
export class ChildElement { | |
show() { | |
this.childRefContent = this.theRef.innerText; | |
} | |
} |
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> | |
<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 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 bindable="model, view"> | |
<require from="./child-element"></require> | |
<div ref="theRef">I am in a parent element.</div> | |
<button click.delegate="show()">Display parent ref content:</button> <span>${parentRefContent}</span> | |
<child-element /> | |
</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, processContent } from "aurelia-framework" | |
@customElement('parent-element') | |
export class ParentElement { | |
show() { | |
this.parentRefContent = this.theRef.innerText; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment