-
Notifications
You must be signed in to change notification settings - Fork 7
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
autorender removes <link>
tags
#41
Comments
Since creating this issue, I think I understand why it does this -> to prevent a double load of script, link, and style tags if the app has been server-side rendered (SSR). The app using I see a few options: 1. Have this project only use
|
You can put links in the body too, so |
Why not start with #3 as it's probably the easiest?
I still think we should do #1, but just warn people they should probably put it in the served HTML for better performance.
…Sent from my iPhone
On Jan 12, 2017, at 7:22 AM, Matthew Phillips ***@***.***> wrote:
You can put links in the body too, so #1 doesn't solve anything. I think we can do #2. We're only talking about links with an href and scripts here so not a big deal to keep a map of the ones already in the page.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Limiting done-autorender to only the <head>
<title>My site | {{page}}</title>
</head>
<body>
...
</body> As far as <html autorender-all>
...
</html> |
Sorry, to be clear, I'm not suggesting the body-only part of Yes for
It would probably be ideal if this was a |
In a disabled mode? Can you clarify what you mean there? |
I mean the style sheet can make the site look a shade of gray before re-attachment, to give the user a clear signal that the site is un-usable. .done-ssred {
color: #808080
} If we remove that |
That makes omitting duplicate links/scripts an opt-in rather than opt-out feature. I don't think it should be opt-in. I don't think anyone ever wants duplicates so they shouldn't have to add a class to prevent them. |
After talking about it with @justinbmeyer sort of concluded that there is no good reason to put scripts or links into both the HTML and the Stache files. You would put them in one or the other, in which case there wouldn't be duplicates. The only scenario for putting it in both is when server rendered. So we're going to have done-autorender add an attribute when being server rendered to the documentElement that gets removed after reattachment. Some ideas for the attribute:
I kind of like unattached or detached. |
Need tests for:
|
This implements a new attribute that is added to the documentElement, *data-detached*. it is added in SSR and removed when attachment is complete on the client. Because of this new attribute, we will insert any links/styles/scripts when that attribute doesn't exist. Fixes #41
This is in 1.0.0-alpha.3, here's how to use it: https://github.com/donejs/autorender/tree/major#server-rendering |
The existing solution has a bug where upon rerendering (for live-reload), because the data-detached attribute is gone it will insert scripts even though they are already there. This causes a problem where the Steal script tag is continuously reinserted and the entire app loads over and over and over. I've reverted the feature since it's such a bad bug temporarily while I fix it. |
This is related to the data-detach feature. During live reload we go through reattachment again, in which case script/link/style elements are on the page. We need to make sure not to insert them again. Closes #41
I reverted this again. This is really hard to get right 😕 You have to maintain state to know if reattachment has occurred and if so, use the old behavior of not push in scripts. Otherwise if you push in a steal script you'll get cycles as it continuously reinserts steal over and over again. This feels a little dangerous to me and I'd like to back away from it and rethink it through a bit. |
@chasenlehara why did you put this on the DoneJS 1.0 release? I don't think it should be. As I detailed about, this is really easy to get wrong and getting it wrong is very bad consequences (causing the browser to lock up, for example). And it serves a pretty niche need (putting links in index.stache but not in your html). |
I put it in the 1.0 release epic because it’s a p1, but we can move it to another release epic or out completely if you don’t think we should address it now or schedule it for a future release. 🙂 |
I don't think this should be part of the 1.0 release or that it's a P1. |
To clarify, I've fixed this twice only to find that it caused even worse bugs. Specifically when coupled with live-reload it would cause steal.js to be inserted multiple times which caused infinite recursion (each time steal.js was inserted it would then re-import your entire app including done-autorender which would then insert steal.js which would re-import your entire app, etc). This can be fixed but given it is highly stately thing I'd want to refactor all of done-autorender to make sure that this feature could be isolated and properly tested for all scenarios. done-autorender's code is already not the best, so I wouldn't want to shove this feature in in a way that isn't readable. |
@matthewp is this issue solved with the current 1.3 release? |
Nope |
so what is the current workaround? |
Put the link tags into your stache file, I think. |
as justin said #41 (comment) , link tags get removed ... so putting them into the stache file dont work. |
In 2.0 you'll be able to keep elements in the DOM using a special data attribute. This is explained in the readme: https://github.com/donejs/autorender/tree/major#keeping-elements-in-the-dom |
Currently, autorender removes
<script>
,<link>
, and<style>
tags that are in the template. This causes bugs when these tags are expected to be part of the page, for example afavicon
:Why are these removed? What can be done to allow these types of tags? Thanks!
cc @lkodai
The text was updated successfully, but these errors were encountered: