Fix: replace deprecated String.prototype.substr with slice (#23915)
Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: Yongtao Huang <99629139+hyongtao-db@users.noreply.github.com>
This commit is contained in:
parent
c39dfad7b6
commit
2476511368
@ -117,7 +117,7 @@ const Flowchart = React.forwardRef((props: {
|
|||||||
const [isInitialized, setIsInitialized] = useState(false)
|
const [isInitialized, setIsInitialized] = useState(false)
|
||||||
const [currentTheme, setCurrentTheme] = useState<'light' | 'dark'>(props.theme || 'light')
|
const [currentTheme, setCurrentTheme] = useState<'light' | 'dark'>(props.theme || 'light')
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
const chartId = useRef(`mermaid-chart-${Math.random().toString(36).substr(2, 9)}`).current
|
const chartId = useRef(`mermaid-chart-${Math.random().toString(36).slice(2, 11)}`).current
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
const renderTimeoutRef = useRef<NodeJS.Timeout>()
|
const renderTimeoutRef = useRef<NodeJS.Timeout>()
|
||||||
const [errMsg, setErrMsg] = useState('')
|
const [errMsg, setErrMsg] = useState('')
|
||||||
|
|||||||
@ -259,7 +259,7 @@ function getFullMatchOffset(
|
|||||||
): number {
|
): number {
|
||||||
let triggerOffset = offset
|
let triggerOffset = offset
|
||||||
for (let i = triggerOffset; i <= entryText.length; i++) {
|
for (let i = triggerOffset; i <= entryText.length; i++) {
|
||||||
if (documentText.substr(-i) === entryText.substr(0, i))
|
if (documentText.slice(-i) === entryText.slice(0, i))
|
||||||
triggerOffset = i
|
triggerOffset = i
|
||||||
}
|
}
|
||||||
return triggerOffset
|
return triggerOffset
|
||||||
|
|||||||
@ -9,7 +9,7 @@ export default function RoutePrefixHandle() {
|
|||||||
const handleRouteChange = () => {
|
const handleRouteChange = () => {
|
||||||
const addPrefixToImg = (e: HTMLImageElement) => {
|
const addPrefixToImg = (e: HTMLImageElement) => {
|
||||||
const url = new URL(e.src)
|
const url = new URL(e.src)
|
||||||
const prefix = url.pathname.substr(0, basePath.length)
|
const prefix = url.pathname.slice(0, basePath.length)
|
||||||
if (prefix !== basePath && !url.href.startsWith('blob:') && !url.href.startsWith('data:')) {
|
if (prefix !== basePath && !url.href.startsWith('blob:') && !url.href.startsWith('data:')) {
|
||||||
url.pathname = basePath + url.pathname
|
url.pathname = basePath + url.pathname
|
||||||
e.src = url.toString()
|
e.src = url.toString()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user