Files
react-native-devtools-frontend/node_modules/postcss-html/template-tokenize.js
T
Mathias Bynens 79e2cf0633 Add stylelint dependency
This also adds CC-BY-4.0 to the list of accepted licenses.

DISABLE_THIRD_PARTY_CHECK=update dependencies

Bug: chromium:1083142
Change-Id: I8612de2fba52dae32eeb71af79d5aacfde52142b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2220097
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
2020-06-11 06:20:04 +00:00

50 lines
948 B
JavaScript

"use strict";
const tokenize = require("postcss/lib/tokenize");
function templateTokenize () {
const tokenizer = tokenize.apply(this, arguments);
function nextToken () {
const args = arguments;
const returned = [];
let token;
let depth = 0;
let line;
let column;
while ((token = tokenizer.nextToken.apply(tokenizer, args))) {
if (token[0] !== "word") {
if (token[0] === "{") {
++depth;
} else if (token[0] === "}") {
--depth;
}
}
if (depth || returned.length) {
line = token[4] || token[2] || line;
column = token[5] || token[3] || column;
returned.push(token);
}
if (!depth) {
break;
}
}
if (returned.length) {
token = [
"word",
returned.map(token => token[1]).join(""),
returned[0][2],
returned[0][3],
line,
column,
];
}
return token;
}
return Object.assign({}, tokenizer, {
nextToken,
});
}
module.exports = templateTokenize;