FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(CSS): import of relative paths by vchimev · Pull Request #6023 · NativeScript/NativeScript · GitHub

feat(CSS): import of relative paths - #6023

Merged
vchimev merged 2 commits into
masterfrom
vchimev/css-import-relative-path
Jul 21, 2018
Merged

vchimev merged 2 commits into
masterfrom
vchimev/css-import-relative-path

Conversation

vchimev commented Jul 4, 2018

Copy link
Copy Markdown
Contributor

Implements #6021.

ghost assigned vchimev Jul 4, 2018
ghost added the in progress label Jul 4, 2018
vchimev requested review from MartoYankov and vakrilov July 4, 2018 06:37
ns-bot added the cla: yes label Jul 4, 2018

function resolveFileNameFromImport(importSource: string, fileName: string): string {
let stack = importSource.split(path.separator),
parts = fileName.split(path.separator);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Since you changed them elsewhere, I think these should be const.

return null;
}

function resolveFileNameFromImport(importSource: string, fileName: string): string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

add comments to explain how this works and format it (missing ;, let -> const, declare every variable with separate statement, etc.)

}

export function resolveFileNameFromUrl(url: string, appDirectory: string, fileExists: (string) => boolean): string;
export function resolveFileNameFromUrl(url: string, appDirectory: string, fileExists: (string) => boolean, importSource?: string): string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why is this exported?

private static uriToRelativePath(uri: string): string {
let appRelativeUri = uri;
if (appRelativeUri.startsWith("/")) {
var app = knownFolders.currentApp().path + "/";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

const

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Stays let - four lines below there is a new assignment of appRelativeUri. Changed var app to let app.

for (let i = 0; i < imports.length; i++) {
const importItem = imports[i]["import"];

const importItemSource = imports[i]["position"]["source"];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

check if imports[i]["position"] is not undefined before accessing ["source"]

if (url !== null && url !== undefined) {
const cssFile = CSSSource.fromURI(url, this._keyframes);
const file = CSSSource.resolveCSSPathFromURL(url, importItemSource);
const cssFile = new CSSSource(undefined, url, file, this._keyframes, undefined);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

use the static method fromFile


if (url !== null && url !== undefined) {
const cssFile = CSSSource.fromURI(url, this._keyframes);
const file = CSSSource.resolveCSSPathFromURL(url, importItemSource);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

what will happen if file is null?

@@ -1409,50 +1409,72 @@ export function test_CascadingClassNamesAppliesAfterPageLoad() {
}

export function test_resolveFileNameFromUrl_local_file_tilda() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Add tests for resolveFileNameFromUrl with the new argument (importSource) as well.

ghost assigned manoldonev Jul 6, 2018
vchimev force-pushed the vchimev/css-import-relative-path branch 2 times, most recently from f480862 to 7e9a6aa Compare July 19, 2018 12:06

const appPath = knownFolders.currentApp().path;
if (!uri.startsWith(appPath)) {
traceWrite("${uri} does not start with ${appPath}", traceCategories.Error, traceMessageType.error);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Backticks (`) instead of quotes (")

vchimev force-pushed the vchimev/css-import-relative-path branch from 7e9a6aa to 2331623 Compare July 19, 2018 12:17
vchimev merged commit 6ce1d22 into master Jul 21, 2018
ghost removed the in progress label Jul 21, 2018
vchimev deleted the vchimev/css-import-relative-path branch July 21, 2018 02:54
vchimev added this to the 4.2 milestone Jul 21, 2018

lock Bot commented Aug 26, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock Bot locked and limited conversation to collaborators Aug 26, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL