-
Notifications
You must be signed in to change notification settings - Fork 0
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
@AngularClass their solution is more elegant imo #1
base: doctype_server_transfer
Are you sure you want to change the base?
@AngularClass their solution is more elegant imo #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typescript Array some method can simplify the for loop
let headNode: any; | ||
|
||
// tslint:disable-next-line:no-inferrable-types | ||
for (let i: number = 0; i < document.childNodes.length; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code can be simplify with .some method
document.childNodes.some(child => isTag('html', child) && !!(rootNode = child));
} | ||
|
||
// tslint:disable-next-line:no-inferrable-types | ||
for (let i: number = 0; i < rootNode.childNodes.length; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this for loop also can be
rootNode.childNodes.some(child => isTag('head', child) && !!(headNode = child));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To sum up, 2 for loop code can be simplified to
let rootNode: any = document;
let headNode: any;
// tslint:disable-next-line:no-inferrable-types
document.childNodes.some(child => isTag('html', child) && !!(rootNode = child));
// tslint:disable-next-line:no-inferrable-types
rootNode.childNodes.some(child => isTag('head', child) && !!(headNode = child));
No description provided.