mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] *: run prettier
This commit is contained in:
@@ -13,7 +13,6 @@ A rendering occurs in two phases:
|
|||||||
- virtual rendering: this generates the virtual dom in memory, asynchronously
|
- virtual rendering: this generates the virtual dom in memory, asynchronously
|
||||||
- patch: applies a virtual tree to the screen (synchronously)
|
- patch: applies a virtual tree to the screen (synchronously)
|
||||||
|
|
||||||
|
|
||||||
There are several classes involved in a rendering:
|
There are several classes involved in a rendering:
|
||||||
|
|
||||||
- components
|
- components
|
||||||
@@ -21,9 +20,9 @@ There are several classes involved in a rendering:
|
|||||||
- fibers: small objects containing some metadata, associated with a rendering of
|
- fibers: small objects containing some metadata, associated with a rendering of
|
||||||
a specific component
|
a specific component
|
||||||
|
|
||||||
|
|
||||||
Components are organized in a dynamic component tree, visible in the user
|
Components are organized in a dynamic component tree, visible in the user
|
||||||
interface. Whenever a rendering is initiated in a component `C`:
|
interface. Whenever a rendering is initiated in a component `C`:
|
||||||
|
|
||||||
- a fiber is created on `C` with the rendering props information
|
- a fiber is created on `C` with the rendering props information
|
||||||
- the virtual rendering phase starts on C (will asynchronously render all the
|
- the virtual rendering phase starts on C (will asynchronously render all the
|
||||||
child components)
|
child components)
|
||||||
@@ -31,4 +30,3 @@ interface. Whenever a rendering is initiated in a component `C`:
|
|||||||
animation frame, if the fiber is done
|
animation frame, if the fiber is done
|
||||||
- once it is done, the scheduler will call the task callback, which will apply
|
- once it is done, the scheduler will call the task callback, which will apply
|
||||||
the patch (if it was not cancelled in the meantime).
|
the patch (if it was not cancelled in the meantime).
|
||||||
|
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ describe("props validation", () => {
|
|||||||
async __updateProps() {
|
async __updateProps() {
|
||||||
try {
|
try {
|
||||||
await Component.prototype.__updateProps.apply(this, arguments);
|
await Component.prototype.__updateProps.apply(this, arguments);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ interface MarkDownSection {
|
|||||||
interface FileData {
|
interface FileData {
|
||||||
name: string;
|
name: string;
|
||||||
path: string[];
|
path: string[];
|
||||||
fullName: string
|
fullName: string;
|
||||||
links: MarkDownLink[];
|
links: MarkDownLink[];
|
||||||
sections: MarkDownSection[];
|
sections: MarkDownSection[];
|
||||||
}
|
}
|
||||||
@@ -31,11 +31,9 @@ interface FileData {
|
|||||||
const LINK_REGEXP = /\[([^\[]+)\]\(([^\)]+)\)/g;
|
const LINK_REGEXP = /\[([^\[]+)\]\(([^\)]+)\)/g;
|
||||||
const HEADING_REGEXP = /\n(#+\s*)(.*)/g;
|
const HEADING_REGEXP = /\n(#+\s*)(.*)/g;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function addMardownData(fileData): void {
|
export function addMardownData(fileData): void {
|
||||||
const sep = fileData.path.length > 0 ? '/' : '';
|
const sep = fileData.path.length > 0 ? "/" : "";
|
||||||
const fullName = fileData.path.join('/') + sep + fileData.name;
|
const fullName = fileData.path.join("/") + sep + fileData.name;
|
||||||
const content = fs.readFileSync(fullName, { encoding: "utf8" });
|
const content = fs.readFileSync(fullName, { encoding: "utf8" });
|
||||||
let m;
|
let m;
|
||||||
// get links info
|
// get links info
|
||||||
@@ -54,7 +52,6 @@ export function addMardownData(fileData): void {
|
|||||||
} while (m);
|
} while (m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of FileData corresponding to all files that need to be
|
* Returns a list of FileData corresponding to all files that need to be
|
||||||
* validated.
|
* validated.
|
||||||
@@ -74,7 +71,7 @@ function getFiles(path: string[] = []): FileData[] {
|
|||||||
if (f.isDirectory()) {
|
if (f.isDirectory()) {
|
||||||
return getFiles(path.concat(f.name));
|
return getFiles(path.concat(f.name));
|
||||||
}
|
}
|
||||||
const fullName = path.join('/') + (path.length > 0 ? '/' : '') + f.name;
|
const fullName = path.join("/") + (path.length > 0 ? "/" : "") + f.name;
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: f.name,
|
name: f.name,
|
||||||
@@ -88,7 +85,7 @@ function getFiles(path: string[] = []): FileData[] {
|
|||||||
return Array.prototype.concat(...files);
|
return Array.prototype.concat(...files);
|
||||||
}
|
}
|
||||||
|
|
||||||
const LOCAL_FILES = ['LICENSE'];
|
const LOCAL_FILES = ["LICENSE"];
|
||||||
export function isLinkValid(link: MarkDownLink, current: FileData, files: FileData[]): boolean {
|
export function isLinkValid(link: MarkDownLink, current: FileData, files: FileData[]): boolean {
|
||||||
if (link.link.startsWith("http")) {
|
if (link.link.startsWith("http")) {
|
||||||
// no check on external links
|
// no check on external links
|
||||||
@@ -99,19 +96,19 @@ export function isLinkValid(link: MarkDownLink, current: FileData, files: FileDa
|
|||||||
// name = 'rendering.md'
|
// name = 'rendering.md'
|
||||||
// hash = 'blabla' (or '' if no hash)
|
// hash = 'blabla' (or '' if no hash)
|
||||||
|
|
||||||
const parts = link.link.split('#');
|
const parts = link.link.split("#");
|
||||||
const hash = parts[1] || '';
|
const hash = parts[1] || "";
|
||||||
let name;
|
let name;
|
||||||
let path;
|
let path;
|
||||||
if (parts[0]) {
|
if (parts[0]) {
|
||||||
let temp = parts[0].split('/');
|
let temp = parts[0].split("/");
|
||||||
name = temp[temp.length - 1];
|
name = temp[temp.length - 1];
|
||||||
temp.splice(-1);
|
temp.splice(-1);
|
||||||
path = current.path.slice();
|
path = current.path.slice();
|
||||||
for (let elem of temp) {
|
for (let elem of temp) {
|
||||||
if (elem === '..') {
|
if (elem === "..") {
|
||||||
path.splice(-1);
|
path.splice(-1);
|
||||||
} else if (elem !== '.') {
|
} else if (elem !== ".") {
|
||||||
path.push(elem);
|
path.push(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +119,7 @@ export function isLinkValid(link: MarkDownLink, current: FileData, files: FileDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step 2: build normalized link file name
|
// Step 2: build normalized link file name
|
||||||
const linkFullName = path.join('/') + (path.length > 0 ? '/' : '') + name;
|
const linkFullName = path.join("/") + (path.length > 0 ? "/" : "") + name;
|
||||||
|
|
||||||
// Step 3: check link name against white list of local files
|
// Step 3: check link name against white list of local files
|
||||||
if (LOCAL_FILES.includes(linkFullName)) {
|
if (LOCAL_FILES.includes(linkFullName)) {
|
||||||
@@ -164,8 +161,6 @@ function slugify(str) {
|
|||||||
.replace(/-+$/, ""); // Trim - from end of text
|
.replace(/-+$/, ""); // Trim - from end of text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Test
|
// Test
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -54,13 +54,12 @@ describe("router miscellaneous", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("navigate in hash mode preserve location", async () => {
|
test("navigate in hash mode preserve location", async () => {
|
||||||
router = new TestRouter(env, [{ name: "users", path: "/users/{{id}}" }], {mode: "hash"});
|
router = new TestRouter(env, [{ name: "users", path: "/users/{{id}}" }], { mode: "hash" });
|
||||||
window.history.pushState({}, "title", window.location.origin + '/test.html');
|
window.history.pushState({}, "title", window.location.origin + "/test.html");
|
||||||
expect(window.location.href).toBe("http://localhost/test.html");
|
expect(window.location.href).toBe("http://localhost/test.html");
|
||||||
await router.navigate({ to: "users", params: { id: 3 } });
|
await router.navigate({ to: "users", params: { id: 3 } });
|
||||||
expect(window.location.href).toBe("http://localhost/test.html#/users/3");
|
expect(window.location.href).toBe("http://localhost/test.html#/users/3");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("routeToPath", () => {
|
describe("routeToPath", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user