Skip to content

Instantly share code, notes, and snippets.

@NullVoxPopuli
Last active June 18, 2020 04:42
Show Gist options
  • Save NullVoxPopuli/5a3fa797b26e8807869340792219a5ee to your computer and use it in GitHub Desktop.
Save NullVoxPopuli/5a3fa797b26e8807869340792219a5ee to your computer and use it in GitHub Desktop.
Repro 18969
<ol>
<li>Open browser dev tools</li>
<li>click "Make True"</li>
<li>click "Make False"</li>
<li>Notice an error in the console</li>
</ol>
<button {{on 'click' this.makeTrue}}>
Make True
</button>
<button {{on 'click' this.makeFalse}}>
Make False
</button>
<hr>
{{#if (eq this.data.kind 'foo')}}
<em>Some Deep Render Requiring nested Data, based on the assumpting that kind is "foo"</em><br>
<pre {{data-attributes-from this.derivedData}}>
this.derivedData: {{this.derivedData}}
</pre>
{{else}}
Click "Make True"
{{/if}}
<hr>
<pre>this.data =
{{as-formatted-string this.data}}
</pre>
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
class Data {
@tracked kind;
@tracked nestedData;
constructor(kind, nestedData) {
this.kind = kind;
this.nestedData = nestedData;
}
toJSON() {
let { kind, nestedData } = this;
return { kind, nestedData };
}
}
export default class DemoRoot extends Component {
@tracked data;
get derivedData() {
return this.data.nestedData.kind;
}
@action
makeTrue() {
this.data = new Data('foo', new Data('baz'));
}
@action
makeFalse() {
this.data = new Data('bar');
}
}
<h1>
Reproduction of
<Link href="https://github.com/emberjs/ember.js/issues/18969">
emberjs/ember.js#18969
</Link>
</h1>
<Link href="https://github.com/NullVoxPopuli/repro-repo-emberjs-18969">Repro Repo</Link>
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import { helper } from '@ember/component/helper';
export default helper(function asFormattedString([a]/*, hash*/) {
return a ? JSON.stringify(a, null, 2) : `${a}`;
});
import { helper } from '@ember/component/helper';
export default helper(function eq([a, b]/*, hash*/) {
return a === b;
});
import Modifier from 'ember-modifier';
export default class DataAttributesFrom extends Modifier {
}
body {
padding: 1rem;
}
<link rel="stylesheet" href="https://cdn.shoelace.style/1.0.0-beta.25/shoelace.css">
<Title />
<br><br>
<Demo />
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0",
"ember-modifier": "1.0.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment