Skip to content

Fix stuff#11200

Merged
filipesilva merged 4 commits intoangular:masterfrom
gkalpak:fix-stuff
Jun 13, 2018
Merged

Fix stuff#11200
filipesilva merged 4 commits intoangular:masterfrom
gkalpak:fix-stuff

Conversation

@gkalpak
Copy link
Copy Markdown
Member

@gkalpak gkalpak commented Jun 11, 2018

The main fix is:

This is a port of angular/devkit#999 from the archived devkit repo (minus the stuff already fixed in #11131).
The NGSW parts have been approved by @alxhub here.


return indent;
// This RegExp is guaranteed to match any string (even if it is a zero-length match).
return (/^ */.exec(text) as RegExpExecArray)[0];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a quick loop instead of the regex (plus tab support):

let indent = '';
for (const char of text) {
    if (char === ' ' || char === '\u0009') {
        indent += char;
    } else {
        break;
    }
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally like RegExps, but happy to change it to whatever you prefer (or even keep the original version).
I just happened to go through the files trying to fix something else and made some changes that made sense to me (and hopefully to others).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm partial to the more self explanatory nature of the loop above then the other two options. And it definitely performs better than the first.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To each his own 😛
Happy to change it to a for loop.

const textToInsertIntoBody = bodyTagIndent + itemsToAddToBody;
const bodyIndent = getIndent(lines[closingBodyTagLineIndex]) + ' ';
const itemsToAddToBody = [
'<noscript>Please enable JavaScript to continue using this application.</noscript>',
Copy link
Copy Markdown
Member

@clydin clydin Jun 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this to the actual template index.html may make sense since it applies to a standard web applications as well. Thoughts?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I guess this was added as poart of @angular/pwa, because good PWA practices include having fallback content for when JS is disabled, but this is indeed useful for non-PWA apps as well.
Should Imove it to index.html?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it eventually should but probably should be left to a separate PR. However, the addition here would need to stay either way to support projects that didn't get created with the new index.html. The code here should be augment now though to check if the noscriptelement is already present and only add if not. Since someone could have added the element manually as well.

Copy link
Copy Markdown
Member Author

@gkalpak gkalpak Jun 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I just realized that a proper solution should also check whether link[rel="manifest"] and meta[name="theme-color"] already exist as well. Since this PR is only refactoring that part of the code (no behavior changes), I'd rather leave the checks for another PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point and works for me.

clydin
clydin previously approved these changes Jun 12, 2018
@clydin
Copy link
Copy Markdown
Member

clydin commented Jun 13, 2018

@gkalpak looks like there was a rebase error with the last commit. Its message is fixup! refactor(@angular/pwa):...

@gkalpak
Copy link
Copy Markdown
Member Author

gkalpak commented Jun 13, 2018

It was intentional (to make it easier to review the changes). It is a "fixup" commit.
The merge scripts in angular/angular support them, but I guess angular/angular-cli has a different process. I'll squash the commits.

@filipesilva filipesilva merged commit 8ce5ef4 into angular:master Jun 13, 2018
@gkalpak gkalpak deleted the fix-stuff branch June 13, 2018 18:13
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ServiceWorker register generated by cli with base-href don't works

4 participants