-
-
Save loaded02/b02295e51c040b48ea84fb6808ffeab5 to your computer and use it in GitHub Desktop.
Reloading Map: Index 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> | |
<require from="./custom"></require> | |
<h1>Reloading Bug</h1> | |
<button click.delegate="reloadArray()">Reload Array</button> | |
<button click.delegate="reloadMap()">Reload Map</button> | |
<h2>Array</h2> | |
<div repeat.for="item of myArray" custom> | |
${item} | |
</div> | |
<h2>Map</h2> | |
<div repeat.for="[key, value] of myMap" custom> | |
<ul> | |
<li repeat.for="item of value">${item}</li> | |
</ul> | |
</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 { | |
constructor() { | |
this.myArray = []; | |
for (let i=0; i<10; i++) { | |
this.myArray.push(i); | |
} | |
this.myMap = new Map(); | |
for (let i=0; i< 10; i++) { | |
this.myMap.set(i, Array(5).fill(i + ' foo bar')); | |
} | |
} | |
reloadMap() { | |
this.myMap.clear(); | |
for (let i=0; i< 10; i++) { | |
this.myMap.set(i, Array(5).fill(i + ' foo bar')); | |
} | |
} | |
reloadArray() { | |
this.myArray.splice(0); | |
for (let i=0; i<10; i++) { | |
this.myArray.push(i + ' reloaded'); | |
} | |
} | |
} |
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 CustomCustomAttribute { | |
bind(bindingContext, overrideContext) { | |
console.log(JSON.stringify(overrideContext.bindingContext), 'index: ', overrideContext.$index, 'first: ', overrideContext.$first, 'last: ', overrideContext.$last) | |
if (overrideContext.$first === true) { | |
console.log("item is first"); | |
} | |
if (overrideContext.$last === true) { | |
console.log("item is last"); | |
} | |
} | |
} | |
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