mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 10:52:35 +02:00
Fixes one warning in console for React.DOM.* usage.
This commit is contained in:
parent
1872df78ae
commit
a83e16308b
2 changed files with 27 additions and 25 deletions
|
@ -10,6 +10,7 @@
|
||||||
/* Marked component is used to parse markdown to html */
|
/* Marked component is used to parse markdown to html */
|
||||||
|
|
||||||
const React = require("react");
|
const React = require("react");
|
||||||
|
import DOM from 'react-dom-factories';
|
||||||
const Prism = require("./Prism.js");
|
const Prism = require("./Prism.js");
|
||||||
const Header = require("./Header.js");
|
const Header = require("./Header.js");
|
||||||
|
|
||||||
|
@ -565,7 +566,7 @@ InlineLexer.prototype.output = function(src) {
|
||||||
text = cap[1];
|
text = cap[1];
|
||||||
href = text;
|
href = text;
|
||||||
}
|
}
|
||||||
out.push(React.DOM.a({ href: this.sanitizeUrl(href) }, text));
|
out.push(DOM.a({ href: this.sanitizeUrl(href) }, text));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,7 +575,7 @@ InlineLexer.prototype.output = function(src) {
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
text = cap[1];
|
text = cap[1];
|
||||||
href = text;
|
href = text;
|
||||||
out.push(React.DOM.a({ href: this.sanitizeUrl(href) }, text));
|
out.push(DOM.a({ href: this.sanitizeUrl(href) }, text));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,35 +619,35 @@ InlineLexer.prototype.output = function(src) {
|
||||||
// strong
|
// strong
|
||||||
if ((cap = this.rules.strong.exec(src))) {
|
if ((cap = this.rules.strong.exec(src))) {
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
out.push(React.DOM.strong(null, this.output(cap[2] || cap[1])));
|
out.push(DOM.strong(null, this.output(cap[2] || cap[1])));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// em
|
// em
|
||||||
if ((cap = this.rules.em.exec(src))) {
|
if ((cap = this.rules.em.exec(src))) {
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
out.push(React.DOM.em(null, this.output(cap[2] || cap[1])));
|
out.push(DOM.em(null, this.output(cap[2] || cap[1])));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// code
|
// code
|
||||||
if ((cap = this.rules.code.exec(src))) {
|
if ((cap = this.rules.code.exec(src))) {
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
out.push(React.DOM.code(null, cap[2]));
|
out.push(DOM.code(null, cap[2]));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// br
|
// br
|
||||||
if ((cap = this.rules.br.exec(src))) {
|
if ((cap = this.rules.br.exec(src))) {
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
out.push(React.DOM.br(null, null));
|
out.push(DOM.br(null, null));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// del (gfm)
|
// del (gfm)
|
||||||
if ((cap = this.rules.del.exec(src))) {
|
if ((cap = this.rules.del.exec(src))) {
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
out.push(React.DOM.del(null, this.output(cap[1])));
|
out.push(DOM.del(null, this.output(cap[1])));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,7 +696,7 @@ InlineLexer.prototype.outputLink = function(cap, link) {
|
||||||
const shouldOpenInNewWindow =
|
const shouldOpenInNewWindow =
|
||||||
link.href.charAt(0) !== "/" && link.href.charAt(0) !== "#";
|
link.href.charAt(0) !== "/" && link.href.charAt(0) !== "#";
|
||||||
|
|
||||||
return React.DOM.a(
|
return DOM.a(
|
||||||
{
|
{
|
||||||
href: this.sanitizeUrl(link.href),
|
href: this.sanitizeUrl(link.href),
|
||||||
title: link.title,
|
title: link.title,
|
||||||
|
@ -704,7 +705,7 @@ InlineLexer.prototype.outputLink = function(cap, link) {
|
||||||
this.output(cap[1])
|
this.output(cap[1])
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return React.DOM.img(
|
return DOM.img(
|
||||||
{
|
{
|
||||||
src: this.sanitizeUrl(link.href),
|
src: this.sanitizeUrl(link.href),
|
||||||
alt: cap[1],
|
alt: cap[1],
|
||||||
|
@ -806,7 +807,7 @@ Parser.prototype.tok = function() {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
case "hr": {
|
case "hr": {
|
||||||
return React.DOM.hr(null, null);
|
return DOM.hr(null, null);
|
||||||
}
|
}
|
||||||
case "heading": {
|
case "heading": {
|
||||||
return (
|
return (
|
||||||
|
@ -835,7 +836,7 @@ Parser.prototype.tok = function() {
|
||||||
for (i = 0; i < this.token.header.length; i++) {
|
for (i = 0; i < this.token.header.length; i++) {
|
||||||
heading = this.inline.output(this.token.header[i]);
|
heading = this.inline.output(this.token.header[i]);
|
||||||
row.push(
|
row.push(
|
||||||
React.DOM.th(
|
DOM.th(
|
||||||
this.token.align[i]
|
this.token.align[i]
|
||||||
? { style: { textAlign: this.token.align[i] } }
|
? { style: { textAlign: this.token.align[i] } }
|
||||||
: null,
|
: null,
|
||||||
|
@ -843,7 +844,7 @@ Parser.prototype.tok = function() {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
table.push(React.DOM.thead(null, React.DOM.tr(null, row)));
|
table.push(DOM.thead(null, DOM.tr(null, row)));
|
||||||
|
|
||||||
// body
|
// body
|
||||||
for (i = 0; i < this.token.cells.length; i++) {
|
for (i = 0; i < this.token.cells.length; i++) {
|
||||||
|
@ -851,7 +852,7 @@ Parser.prototype.tok = function() {
|
||||||
cells = this.token.cells[i];
|
cells = this.token.cells[i];
|
||||||
for (j = 0; j < cells.length; j++) {
|
for (j = 0; j < cells.length; j++) {
|
||||||
row.push(
|
row.push(
|
||||||
React.DOM.td(
|
DOM.td(
|
||||||
this.token.align[j]
|
this.token.align[j]
|
||||||
? { style: { textAlign: this.token.align[j] } }
|
? { style: { textAlign: this.token.align[j] } }
|
||||||
: null,
|
: null,
|
||||||
|
@ -859,11 +860,11 @@ Parser.prototype.tok = function() {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
body.push(React.DOM.tr(null, row));
|
body.push(DOM.tr(null, row));
|
||||||
}
|
}
|
||||||
table.push(React.DOM.thead(null, body));
|
table.push(DOM.thead(null, body));
|
||||||
|
|
||||||
return React.DOM.table(null, table);
|
return DOM.table(null, table);
|
||||||
}
|
}
|
||||||
case "blockquote_start": {
|
case "blockquote_start": {
|
||||||
const body = [];
|
const body = [];
|
||||||
|
@ -872,7 +873,7 @@ Parser.prototype.tok = function() {
|
||||||
body.push(this.tok());
|
body.push(this.tok());
|
||||||
}
|
}
|
||||||
|
|
||||||
return React.DOM.blockquote(null, body);
|
return DOM.blockquote(null, body);
|
||||||
}
|
}
|
||||||
case "list_start": {
|
case "list_start": {
|
||||||
const type = this.token.ordered ? "ol" : "ul";
|
const type = this.token.ordered ? "ol" : "ul";
|
||||||
|
@ -882,7 +883,7 @@ Parser.prototype.tok = function() {
|
||||||
body.push(this.tok());
|
body.push(this.tok());
|
||||||
}
|
}
|
||||||
|
|
||||||
return React.DOM[type](null, body);
|
return DOM[type](null, body);
|
||||||
}
|
}
|
||||||
case "list_item_start": {
|
case "list_item_start": {
|
||||||
const body = [];
|
const body = [];
|
||||||
|
@ -891,7 +892,7 @@ Parser.prototype.tok = function() {
|
||||||
body.push(this.token.type === "text" ? this.parseText() : this.tok());
|
body.push(this.token.type === "text" ? this.parseText() : this.tok());
|
||||||
}
|
}
|
||||||
|
|
||||||
return React.DOM.li(null, body);
|
return DOM.li(null, body);
|
||||||
}
|
}
|
||||||
case "loose_item_start": {
|
case "loose_item_start": {
|
||||||
const body = [];
|
const body = [];
|
||||||
|
@ -900,10 +901,10 @@ Parser.prototype.tok = function() {
|
||||||
body.push(this.tok());
|
body.push(this.tok());
|
||||||
}
|
}
|
||||||
|
|
||||||
return React.DOM.li(null, body);
|
return DOM.li(null, body);
|
||||||
}
|
}
|
||||||
case "html": {
|
case "html": {
|
||||||
return React.DOM.div({
|
return DOM.div({
|
||||||
dangerouslySetInnerHTML: {
|
dangerouslySetInnerHTML: {
|
||||||
__html: this.token.text
|
__html: this.token.text
|
||||||
}
|
}
|
||||||
|
@ -915,12 +916,12 @@ Parser.prototype.tok = function() {
|
||||||
null,
|
null,
|
||||||
this.inline.output(this.token.text)
|
this.inline.output(this.token.text)
|
||||||
)
|
)
|
||||||
: React.DOM.p(null, this.inline.output(this.token.text));
|
: DOM.p(null, this.inline.output(this.token.text));
|
||||||
}
|
}
|
||||||
case "text": {
|
case "text": {
|
||||||
return this.options.paragraphFn
|
return this.options.paragraphFn
|
||||||
? this.options.paragraphFn.call(null, this.parseText())
|
? this.options.paragraphFn.call(null, this.parseText())
|
||||||
: React.DOM.p(null, this.parseText());
|
: DOM.p(null, this.parseText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1045,8 +1046,8 @@ function marked(src, opt, callback) {
|
||||||
e.message += "\nPlease report this to https://github.com/chjj/marked.";
|
e.message += "\nPlease report this to https://github.com/chjj/marked.";
|
||||||
if ((opt || marked.defaults).silent) {
|
if ((opt || marked.defaults).silent) {
|
||||||
return [
|
return [
|
||||||
React.DOM.p(null, "An error occurred:"),
|
DOM.p(null, "An error occurred:"),
|
||||||
React.DOM.pre(null, e.message)
|
DOM.pre(null, e.message)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
"prettier": "^1.5.3",
|
"prettier": "^1.5.3",
|
||||||
"react": "^15.5.4",
|
"react": "^15.5.4",
|
||||||
"react-dom": "^15.5.4",
|
"react-dom": "^15.5.4",
|
||||||
|
"react-dom-factories": "^1.0.1",
|
||||||
"request": "^2.81.0",
|
"request": "^2.81.0",
|
||||||
"shelljs": "^0.7.8"
|
"shelljs": "^0.7.8"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue