-
-
Save sahithyandev/41630e04f1399a58fd693b8f7611c028 to your computer and use it in GitHub Desktop.
Aurelia problem with Set
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
.normal { | |
font-weight: bold; | |
font-size: 2rem; | |
} | |
.click-toggle { | |
color: red; | |
} |
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="./app.css"></require> | |
<div class.bind="classNames.join(' ')" click.delegate="clickListner()"> | |
${message} | |
</div> | |
<div innerhtml.bind="classNames.join(' ')"></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
Set.prototype.join = function (seperator = ' ') { | |
return Array.from(this).join(seperator); | |
} | |
export class App { | |
classNames = new Set().add('normal'); | |
message = 'Hello World!'; | |
clickListner() { | |
if (this.classNames.has('click-toggle')) { | |
this.classNames.delete('click-toggle'); | |
} else { | |
this.classNames.add('click-toggle'); | |
} | |
this.classNames = new Set(this.classNames); | |
} | |
} |
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment