-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An anchor tag in dialog-body causes infinite loop #283
Comments
Will check after #281, probably the same cause. |
I'm not able to reproduce this - Chrome 58.0.3029.81. Does it crash when you open it or after some interaction? A repro is appreciated. |
Edit: also created this: https://github.com/larserikfinholt/aurelia-dialog-err ok, did take the latest typescript webpack skeleton, and reproduced with the following (I'll add each step, maybe you can spot where I'm going wrong) index.ejs package.json main.ts welcome.html welcome.ts
request-dialog.html
request-dialog.ts
Error shows up when clicking the button. |
@jods4 @EisenbergEffect Some help would be appreciated. I can not reproduce with non-webpack build. The recursion starts in
Loops back to 1. |
I don't see how that could be even remotely linked to Webpack... What strikes me as odd is that this Which |
@jods4 in the bundle in |
It's the compiled import/export. Everything is renamed, Webpack leaves comments so that you can figure out what is what.
So I read the code above like: import { metadata } from "aurelia-metadata";
var m = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, context.viewModel.constructor); |
@jods4 I found the issue, the |
@StrahilKazlachev OK I see. Some background:
But the tricky part of Typical pattern for a normal custom element is to register it through In contrast, typical pattern with import { MyDialog } from 'dialogs/whatever';
dialogService.open({ viewModel: MyDialog }); And this is pure ES imports, pure Webpack. The name of I've come to hate Aurelia's reliance on class and module names, they really don't play well with modern bundling tools. I wish we could just deprecate those approaches. I am not familiar with A stopgap measure is to register your dialog ViewModels as Aurelia dependencies. For example by placing a |
@jods4 Mmm, we basically delegate all the lifting to the
|
@larserikfinholt Not a bug in the dialog. |
@StrahilKazlachev Thanks for you attention to this issue, and for finding a workaround. Thanks again for your contributions to aurelia. |
@StrahilKazlachev Maybe we should open an issue in I'm no expert, but my understanding of this code: I can't see a good use for that fallback and it's obviously a dangerous behavior. |
Aurelia does not rely on class names. It relies on export names which should be preserved since they are part of the public API contract for a module. |
Right. It never looks at the class name directly but at the module export name.
Depending on module names and export names is a pain point of our Webpack setup. It creates problems and prevents optimizations. But we have to live with it for the time being.
A library has a public API surface. A bundled application not so much. @larserikfinholt Here's another workaround that should work: use I see two fundamental issues at play here:
@EisenbergEffect I think 2 is a bug in |
In case others have the same trouble. A few workarounds has been presented in this thread, I ended up with this one that works fine: In
|
That's a work-around but I think it's less than ideal and I'm pretty sure others will hit this. @larserikfinholt |
Tracked in aurelia/templating#549 |
We've hit the same issue moving from our previous systemjs/jspm setup to webpack. Is there a way to get webpack to stop shortening the names for these modules? |
@StrahilKazlachev thanks for the quick reply! Yeah, we tried the |
As far as I've understood - no. @jods4 ☝️ am I wrong? |
@eamodio I don't think so but I would need to dive into Webpack source code to be sure. You can try to work-around it in a few ways, though...
This is far from ideal and the bug is pretty bad. I don't think it is receiving the attention it needs, you can make yourself heard in aurelia/templating#549. |
@jods4 Thank you for the follow up. We weren't able to get Yeah, agree that the bug is pretty bad -- we lost quite a bit of time going nuts before we found this issue. Though I'm not sure I'm totally understanding the issue aurelia/templating#549 or more accurately the implications of a change. If that change were to be made, then any class that was to be used as a custom element in a template would need to be named Is another option here, a blacklist of known/common html elements to avoid this issue? Or some other way to deal with it? |
That seems pretty bad. So any exported class in your resources is a custom element? Why not a custom attribute, value converter or binding behavior? The breakage will bad indeed, where did you get the idea to go like this? |
We do use the conventions for the value converters and the decorators for attributes, but we've never used them on elements -- mainly because we didn't know about it (and it works without them), but also thinking about it now, that would mean most of the classes in our app would have I swear I've seen demos by Rob that never used the Also from the docs on the Aurelia site: http://aurelia.io/hub.html#/doc/article/aurelia/templating/latest/templating-custom-elements/3
Granted it follows up with
|
@eamodio good points, I will add a comment in the other issue, because it's where this problem is currently tracked. |
Since it seems that aurelia/templating#549 would be quite a breaking change, since it is a "supported" (even if slightly discouraged) scenario -- is there a much easier (low risk) fix here? |
@jods4 doh -- should I move my last comment over to that issue too? |
Hey folks, just to let you know: So I'll comment them out for the moment, but is there still no workaround / solution for this? |
The cause of this problem is identified but not fixed... It's currently tracked by aurelia/templating#549. The workarounds above should work, though. // DON'T
import { MyDialog } from 'dialogs/whatever';
dialogService.open({ viewModel: MyDialog });
// DO
dialogService.open({ viewModel: PLATFORM.moduleName('dialogs/whatever') });
// ...or at least combine them into:
import { MyDialog } from 'dialogs/whatever';
PLATFORM.moduleName('dialogs/whatever');
dialogService.open({ viewModel: MyDialog }); Independently of this bug, more problems have arisen when using the first pattern with Webpack. Bottom line: when using Webpack, always use |
Thanks again for summing it all up @jods4! Though I think I phrased my question wrong. The workarounds for loading viewmodels work well. |
You should be able to use |
No, I still run into an infinite loop. Here's what I do: package.json
modal.html
I load the viewmodel with It crashes as soon as it sees the EDIT: So the whole thing looks like this:
|
Does it go away if you don't pass the With |
Okay I figured out what was going on! I have my dialog resources configured as Sorry for the hassle and thanks for your time! |
Why is this closed? |
@jholland918 scroll above, up to the "close issue" event, look at the last comment:
|
@jods4 thanks, I didn't see it was tracked in aurelia/templating#549 :) |
No problem. |
Sometimes We have such DialogService's ensureViewModel method after compilation using Webpack:
Then we go to this line:
And it becomes And then Then we go to this line
Which leads us to this method
Here we have
Here How can I get through it? |
I see that you are using import {ACLEditor} from 'core/acl/acl-editor';
PLATFORM.moduleName('core/acl/acl-editor', 'core');
...
this.dialogService.open({
viewModel: 'core/acl/acl-editor',
model: {
...
},
}); |
@bigopon thanks! It helped. |
I'm submitting a bug report
1.0.0-rc.1.0.1
Please tell us about your environment:
Windows 10
Node Version:
6.10.0
NPM Version:
4.0.5
Webpack
webpack 2.4.1
Browser:
chrome
Language:
TypeScript 2.3
Current behavior:
Dialog goes into recurisve loop and terminates with a stackoverflow exception when there is an anchor tag in the dialog body
Expected/desired behavior:
Using this view:
The text was updated successfully, but these errors were encountered: