- How the browser renders the document
- Receives the data (bytes) from the server.
- Parses and converts into tokens (<, TagName, Attribute, AttributeValue, >).
- Turns tokens into nodes.
- Turns nodes into the
DOM
tree.
- Builds
CSSOM
tree from thecss rules
.
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
const Ω = new Proxy(new WeakMap, { | |
set (weakmap, reference, input) { | |
const invocable = eval(reference); | |
if (typeof invocable != 'function') return; | |
weakmap.set(invocable, | |
Array.isArray(input) | |
? invocable(...input) | |
: invocable(input) | |
); | |
}, |
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
/** | |
* Ultimate version solving circular dependency with weakMap | |
* Problems: | |
* 1. Symbols not covered | |
* | |
* @param {Object} sourceObj | |
* @param {WeakMap} [hash=new WeakMap()] | |
* @returns | |
*/ | |
var deepCloneUltimate = (sourceObj, hash = new WeakMap()) => { |
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
// A state machine that works from a description including explicit transitions, | |
// and can generate a transition map and a digraph | |
const STATES = Symbol("states"); | |
const STARTING_STATE = Symbol("starting-state"); | |
const TRANSITIONS = Symbol("transitions"); | |
const RESERVED = [STARTING_STATE, TRANSITIONS]; | |
const MACHINES_TO_CURRENT_STATE_NAMES = new WeakMap(); | |
const MACHINES_TO_STARTING_STATES = new WeakMap(); |
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
// 通过 typeof 来查看每种数据类型的描述 | |
// [undefined, null, true, '', 0, Symbol(), {}].map(it => typeof it) | |
// ["undefined", "object", "boolean", "string", "number", "symbol", "object"] | |
function clone(obj) { | |
// 添加一个 WeakMap 来记录已经拷贝过的对象,如果当前对象已经被拷贝过,那么直接从 WeakMap 中取出,否则重新创建一个对象并加入 WeakMap 中 | |
// ES6 推出的 WeakMap 对象,该对象是一组键/值对的集合,其中的键是弱引用的。其键必须是对象,而值可以是任意的 | |
let map = new WeakMap(); | |
function deep(data) { |
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
% Preamble | |
\usepackage{tikz-uml} | |
\usetikzlibrary{positioning} | |
% Preamble end | |
... | |
\begin{tikzpicture}[shorten >=1pt,node distance=3cm,auto]%,on grid | |
\tikzstyle{state}=[shape=circle,thick,draw,minimum size=1.5cm] | |
\node[state] (A1) {$A_1$}; | |
\node[state,above of=A1] (B1) {$B_1$}; |
How to install tikz-uml package on Mac
#!/bin/sh
mkdir -p ~/Library/texmf/tex/latex/tikz-uml/ # It doesn't really matter where to save this file
cp ~/Downloads/tikzuml-v1.0b/tikz-uml.sty ~/Library/texmf/tex/latex/tikz-uml/
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
/** | |
* This function accepts array of strings or strings or both | |
* all empty or falsy values are omitted | |
* returns a string of classes | |
*@example | |
// 1) simple use case: single argument - array of strings | |
stringifyClasses([ | |
styles.day, | |
isPassive && styles.dayPassive, | |
disabled && styles.dayDisabled, |
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
detectBrowserlanguage(defaultLang) { | |
const navLang = navigator.language || navigator.userLanguage || defaultLang; | |
return navLang.substring(0, 2); | |
} | |
componentDidMount() { | |
const defaultLang = this.detectBrowserlanguage("en"); | |
const lang = localStorage.getItem("user-lang"); | |
const usedLang = lang ? lang : defaultLang; |
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
/** | |
* MyNewType definition | |
* @typedef {MyNewType} MyNewType | |
* @param {number} first | |
* @param {number} second | |
* @property {function} logFirst | |
* @property {function} logSecond | |
* @returns MyNewType | |
*/ |
NewerOlder