Last active
May 3, 2018 04:47
-
-
Save brantwedel/b6dac1c04a230db45afc8825f499edf5 to your computer and use it in GitHub Desktop.
template-binding shorthand css property bug
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> | |
<h1>${message}</h1> | |
<div ref="borderDiv" click.delegate="toggleBorder()" css="${borderCss}"> | |
<h2>Click to toggle my border</h2> | |
<hr> | |
<h4>css binding:</h4> | |
<code>${borderCss}</code> | |
<hr> | |
<h4>actual style attribute:</h4> | |
<code>${actualBorderStyle}</code> | |
</div> | |
<hr> | |
<div click.delegate="toggle = !toggle" css="${toggle ? 'border: 2px solid green' : 'border-left: 2px solid green'}"> | |
Click for simple Toggle Example | |
</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
export class App { | |
message = 'Border Test'; | |
borderState = true; | |
borderDiv = undefined; | |
get borderCss() { | |
if (this.borderState) { | |
return 'border: 2px solid black; content: "this works before toggling, but the second time, all borders are set except left because style.removeProperty(\'border-left\') happens after style.setProperty(\'border\')"'; | |
} else { | |
return 'border-left: 8px solid black; content: "this does not work, because .styles.removeProperty(\'border\') is called, removing the just added border-left"'; | |
} | |
} | |
get actualBorderStyle() { | |
if (this.borderDiv) { | |
return this.borderDiv.getAttribute('style'); | |
} | |
} | |
toggleBorder() { | |
this.borderState = !this.borderState; | |
} | |
} |
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 {inject} from 'aurelia-dependency-injection' | |
export class Action1Dependency {} | |
export class Action2Dependency {} | |
export class ActionBase{ | |
} | |
@inject(Action1Dependency) | |
export class Action1 extends ActionBase{ | |
constructor(dep){ | |
super(); | |
this.dep = dep; | |
} | |
} | |
@inject(Action2Dependency) | |
export class Action2 extends ActionBase{ | |
constructor(dep){ | |
super(); | |
this.dep = dep; | |
} | |
} |
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://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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment