From 3ec7c89bbb3f9562c56e1423d1f67801289bcd34 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 28 Jan 2017 11:11:58 +0800 Subject: [PATCH 1/3] fix initialize the Vue instance --- src/render.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/render.js b/src/render.js index 82f944516..e73c38734 100644 --- a/src/render.js +++ b/src/render.js @@ -112,12 +112,13 @@ export function renderArticle (content) { document.body.querySelectorAll('article>script')) .filter(script => !/template/.test(script.type) )[0] + const code = script ? script.innerText.trim() : null - CACHE.vm = script - ? new Function(`return ${script.innerText.trim()}`)() + script && script.remove() + CACHE.vm = code + ? new Function(`return ${code}`)() : new Vue({ el: 'main' }) // eslint-disable-line CACHE.vm && CACHE.vm.$nextTick(_ => event.scrollActiveSidebar()) - script && script.remove() } if (OPTIONS.auto2top) setTimeout(() => event.scroll2Top(OPTIONS.auto2top), 0) } From a35a336d0023da6495dcae2d46c1d6242eb067b6 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 28 Jan 2017 11:12:22 +0800 Subject: [PATCH 2/3] bump 1.10.5 --- CHANGELOG.md | 4 ++++ docs/_coverpage.md | 2 +- lib/docsify.js | 7 ++++--- lib/docsify.min.js | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d09668f7..713d6f629 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.10.5 +### Bug fixes +- fix initialize the Vue instance + ## 1.10.4 ### Bug fixes - fix execute script diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 2fa8efeda..39180a4fe 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](_media/icon.svg) -# docsify 1.10.4 +# docsify 1.10.5 > A magical documentation site generator. diff --git a/lib/docsify.js b/lib/docsify.js index 0d2e66fa6..f0bfe7e0e 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -2603,12 +2603,13 @@ function renderArticle (content) { document.body.querySelectorAll('article>script')) .filter(function (script) { return !/template/.test(script.type); } )[0]; + var code = script ? script.innerText.trim() : null; - CACHE.vm = script - ? new Function(("return " + (script.innerText.trim())))() + script && script.remove(); + CACHE.vm = code + ? new Function(("return " + code))() : new Vue({ el: 'main' }); // eslint-disable-line CACHE.vm && CACHE.vm.$nextTick(function (_) { return scrollActiveSidebar(); }); - script && script.remove(); } if (OPTIONS$1.auto2top) { setTimeout(function () { return scroll2Top(OPTIONS$1.auto2top); }, 0); } } diff --git a/lib/docsify.min.js b/lib/docsify.min.js index f6a142253..1f21a57f1 100644 --- a/lib/docsify.min.js +++ b/lib/docsify.min.js @@ -1,2 +1,2 @@ -var Docsify=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var a=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(a)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var a=e.level||1,i=a-1;a>t||(r[i]?(r[i].children=r[i].children||[],r[i].children.push(e)):n.push(e),r[a]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function a(){var e=window.location;if(q===e.hash&&!r(A))return A;var t=e.hash.match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,A=t,q=e.hash,t}function i(){return document.body.clientWidth<=600}function s(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(s.occurrences=s.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var a=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),i=s.occurrences[a];return s.occurrences.hasOwnProperty(a)?i++:i=0,s.occurrences[a]=i,i&&(a=a+"-"+i),a}function o(e){return e.replace(/:(\w*?):/gi,'$1').replace(/__colon__/g,":")}function l(){function e(){for(var e,i=document.body.scrollTop,o=0,c=n.length;oi){e||(e=u);break}e=u}if(e){var p=s[e.getAttribute("data-id")];if(p&&p!==l&&(l&&l.classList.remove("active"),p.classList.add("active"),l=p,!t&&!g.noSticky)){var d=0,h=l.offsetTop+l.clientHeight+40,f=l.offsetTop>=r.scrollTop&&h<=r.scrollTop+a,m=h-d=e||g.dom.classList.contains("hidden")?(document.body.classList.add("sticky"),g.noSticky=!1):(document.body.classList.remove("sticky"),g.noSticky=!0)}()}function h(e,t){return t={exports:{}},e(t,t.exports),t.exports}function f(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function m(e){var t=e+'';return(i()?t+"
":"
"+t)+'
\n
\n
\n
'}function b(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
\n
\n
\n
'}function v(){return''}function y(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
  • '+e.title+"
  • ",e.children&&(t+='
    • '+y(e.children)+"
    ")}),t):""}function k(e,t){return'

    '+t.slice(5).trim()+"

    "}function w(e){P=e;var t=new M.Renderer;t.heading=function(e,t){var n=s(e),r="";return P.router&&(r="#/"+a()),F.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+e+""},t.code=function(e,t){void 0===t&&(t="");var n=N.highlight(e,N.languages[t]||N.languages.markup);return'
    '+n.replace(/:/g,"__colon__")+"
    "},t.link=function(e,t,n){return P.router&&!/:/.test(e)&&(e=("#/"+e).replace(/\/\//g,"/")),''+n+""},t.paragraph=function(e){return/^!>/.test(e)?k("tip",e):/^\?>/.test(e)?k("warn",e):"

    "+e+"

    "},"function"==typeof P.markdown?(I.setOptions({renderer:t}),I=P.markdown.call(this,I)):I.setOptions(j({renderer:t},P.markdown));var n=I;I=function(e){return o(n(e))}}function x(e,t){var n=document.querySelector("nav")||document.createElement("nav");P.repo||n.classList.add("no-badge"),e[t?"outerHTML":"innerHTML"]=f(P.repo)+(P.coverpage?b():"")+m(P.sidebarToggle?v():""),document.body.insertBefore(n,document.body.children[0]),p("button.sidebar-toggle"),P.coverpage?!i()&&window.addEventListener("scroll",g):document.body.classList.add("sticky")}function L(e){if(z("article",e?I(e):"not found"),P.sidebar||P.loadSidebar||_(),e&&"undefined"!=typeof Vue){W.vm&&W.vm.$destroy();var t=[].slice.call(document.body.querySelectorAll("article>script")).filter(function(e){return!/template/.test(e.type)})[0];W.vm=t?new Function("return "+t.innerText.trim())():new Vue({el:"main"}),W.vm&&W.vm.$nextTick(function(e){return l()}),t&&t.remove()}P.auto2top&&setTimeout(function(){return d(P.auto2top)},0)}function S(e){W.navbar&&W.navbar===e||(W.navbar=e,e&&z("nav",I(e)),u("nav"))}function _(e){var n;e?(n=I(e),n=n.match(/]*>([\s\S]+)<\/ul>/g)[0]):n=P.sidebar?y(P.sidebar,"