Update hljs to 9.8.0
This commit is contained in:
parent
63e4caf59c
commit
22b9783d07
6 changed files with 122 additions and 93 deletions
|
|
@ -33,7 +33,7 @@
|
|||
<!-- Custom styles for this template -->
|
||||
<link href="main.min.css" rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/styles/github.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/github.min.css">
|
||||
|
||||
<!-- diff2html -->
|
||||
<link rel="stylesheet" type="text/css" href="assets/diff2html.min.css">
|
||||
|
|
@ -240,8 +240,8 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/languages/scala.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/languages/scala.min.js"></script>
|
||||
|
||||
<!-- diff2html -->
|
||||
<script type="text/javascript" src="assets/diff2html.min.js"></script>
|
||||
|
|
|
|||
167
docs/demo.js
167
docs/demo.js
|
|
@ -21,6 +21,28 @@
|
|||
arrayBuffer: 'ArrayBuffer' in self
|
||||
}
|
||||
|
||||
if (support.arrayBuffer) {
|
||||
var viewClasses = [
|
||||
'[object Int8Array]',
|
||||
'[object Uint8Array]',
|
||||
'[object Uint8ClampedArray]',
|
||||
'[object Int16Array]',
|
||||
'[object Uint16Array]',
|
||||
'[object Int32Array]',
|
||||
'[object Uint32Array]',
|
||||
'[object Float32Array]',
|
||||
'[object Float64Array]'
|
||||
]
|
||||
|
||||
var isDataView = function(obj) {
|
||||
return obj && DataView.prototype.isPrototypeOf(obj)
|
||||
}
|
||||
|
||||
var isArrayBufferView = ArrayBuffer.isView || function(obj) {
|
||||
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeName(name) {
|
||||
if (typeof name !== 'string') {
|
||||
name = String(name)
|
||||
|
|
@ -74,12 +96,8 @@
|
|||
Headers.prototype.append = function(name, value) {
|
||||
name = normalizeName(name)
|
||||
value = normalizeValue(value)
|
||||
var list = this.map[name]
|
||||
if (!list) {
|
||||
list = []
|
||||
this.map[name] = list
|
||||
}
|
||||
list.push(value)
|
||||
var oldValue = this.map[name]
|
||||
this.map[name] = oldValue ? oldValue+','+value : value
|
||||
}
|
||||
|
||||
Headers.prototype['delete'] = function(name) {
|
||||
|
|
@ -87,12 +105,8 @@
|
|||
}
|
||||
|
||||
Headers.prototype.get = function(name) {
|
||||
var values = this.map[normalizeName(name)]
|
||||
return values ? values[0] : null
|
||||
}
|
||||
|
||||
Headers.prototype.getAll = function(name) {
|
||||
return this.map[normalizeName(name)] || []
|
||||
name = normalizeName(name)
|
||||
return this.has(name) ? this.map[name] : null
|
||||
}
|
||||
|
||||
Headers.prototype.has = function(name) {
|
||||
|
|
@ -100,15 +114,15 @@
|
|||
}
|
||||
|
||||
Headers.prototype.set = function(name, value) {
|
||||
this.map[normalizeName(name)] = [normalizeValue(value)]
|
||||
this.map[normalizeName(name)] = normalizeValue(value)
|
||||
}
|
||||
|
||||
Headers.prototype.forEach = function(callback, thisArg) {
|
||||
Object.getOwnPropertyNames(this.map).forEach(function(name) {
|
||||
this.map[name].forEach(function(value) {
|
||||
callback.call(thisArg, value, name, this)
|
||||
}, this)
|
||||
}, this)
|
||||
for (var name in this.map) {
|
||||
if (this.map.hasOwnProperty(name)) {
|
||||
callback.call(thisArg, this.map[name], name, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Headers.prototype.keys = function() {
|
||||
|
|
@ -153,14 +167,36 @@
|
|||
|
||||
function readBlobAsArrayBuffer(blob) {
|
||||
var reader = new FileReader()
|
||||
var promise = fileReaderReady(reader)
|
||||
reader.readAsArrayBuffer(blob)
|
||||
return fileReaderReady(reader)
|
||||
return promise
|
||||
}
|
||||
|
||||
function readBlobAsText(blob) {
|
||||
var reader = new FileReader()
|
||||
var promise = fileReaderReady(reader)
|
||||
reader.readAsText(blob)
|
||||
return fileReaderReady(reader)
|
||||
return promise
|
||||
}
|
||||
|
||||
function readArrayBufferAsText(buf) {
|
||||
var view = new Uint8Array(buf)
|
||||
var chars = new Array(view.length)
|
||||
|
||||
for (var i = 0; i < view.length; i++) {
|
||||
chars[i] = String.fromCharCode(view[i])
|
||||
}
|
||||
return chars.join('')
|
||||
}
|
||||
|
||||
function bufferClone(buf) {
|
||||
if (buf.slice) {
|
||||
return buf.slice(0)
|
||||
} else {
|
||||
var view = new Uint8Array(buf.byteLength)
|
||||
view.set(new Uint8Array(buf))
|
||||
return view.buffer
|
||||
}
|
||||
}
|
||||
|
||||
function Body() {
|
||||
|
|
@ -168,7 +204,9 @@
|
|||
|
||||
this._initBody = function(body) {
|
||||
this._bodyInit = body
|
||||
if (typeof body === 'string') {
|
||||
if (!body) {
|
||||
this._bodyText = ''
|
||||
} else if (typeof body === 'string') {
|
||||
this._bodyText = body
|
||||
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
||||
this._bodyBlob = body
|
||||
|
|
@ -176,11 +214,12 @@
|
|||
this._bodyFormData = body
|
||||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
||||
this._bodyText = body.toString()
|
||||
} else if (!body) {
|
||||
this._bodyText = ''
|
||||
} else if (support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) {
|
||||
// Only support ArrayBuffers for POST method.
|
||||
// Receiving ArrayBuffers happens via Blobs, instead.
|
||||
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
||||
this._bodyArrayBuffer = bufferClone(body.buffer)
|
||||
// IE 10-11 can't handle a DataView body.
|
||||
this._bodyInit = new Blob([this._bodyArrayBuffer])
|
||||
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
||||
this._bodyArrayBuffer = bufferClone(body)
|
||||
} else {
|
||||
throw new Error('unsupported BodyInit type')
|
||||
}
|
||||
|
|
@ -205,6 +244,8 @@
|
|||
|
||||
if (this._bodyBlob) {
|
||||
return Promise.resolve(this._bodyBlob)
|
||||
} else if (this._bodyArrayBuffer) {
|
||||
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
||||
} else if (this._bodyFormData) {
|
||||
throw new Error('could not read FormData body as blob')
|
||||
} else {
|
||||
|
|
@ -213,8 +254,13 @@
|
|||
}
|
||||
|
||||
this.arrayBuffer = function() {
|
||||
if (this._bodyArrayBuffer) {
|
||||
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
|
||||
} else {
|
||||
return this.blob().then(readBlobAsArrayBuffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.text = function() {
|
||||
var rejected = consumed(this)
|
||||
|
|
@ -224,18 +270,14 @@
|
|||
|
||||
if (this._bodyBlob) {
|
||||
return readBlobAsText(this._bodyBlob)
|
||||
} else if (this._bodyArrayBuffer) {
|
||||
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
||||
} else if (this._bodyFormData) {
|
||||
throw new Error('could not read FormData body as text')
|
||||
} else {
|
||||
return Promise.resolve(this._bodyText)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.text = function() {
|
||||
var rejected = consumed(this)
|
||||
return rejected ? rejected : Promise.resolve(this._bodyText)
|
||||
}
|
||||
}
|
||||
|
||||
if (support.formData) {
|
||||
this.formData = function() {
|
||||
|
|
@ -261,7 +303,10 @@
|
|||
function Request(input, options) {
|
||||
options = options || {}
|
||||
var body = options.body
|
||||
if (Request.prototype.isPrototypeOf(input)) {
|
||||
|
||||
if (typeof input === 'string') {
|
||||
this.url = input
|
||||
} else {
|
||||
if (input.bodyUsed) {
|
||||
throw new TypeError('Already read')
|
||||
}
|
||||
|
|
@ -272,12 +317,10 @@
|
|||
}
|
||||
this.method = input.method
|
||||
this.mode = input.mode
|
||||
if (!body) {
|
||||
if (!body && input._bodyInit != null) {
|
||||
body = input._bodyInit
|
||||
input.bodyUsed = true
|
||||
}
|
||||
} else {
|
||||
this.url = input
|
||||
}
|
||||
|
||||
this.credentials = options.credentials || this.credentials || 'omit'
|
||||
|
|
@ -295,7 +338,7 @@
|
|||
}
|
||||
|
||||
Request.prototype.clone = function() {
|
||||
return new Request(this)
|
||||
return new Request(this, { body: this._bodyInit })
|
||||
}
|
||||
|
||||
function decode(body) {
|
||||
|
|
@ -311,16 +354,17 @@
|
|||
return form
|
||||
}
|
||||
|
||||
function headers(xhr) {
|
||||
var head = new Headers()
|
||||
var pairs = (xhr.getAllResponseHeaders() || '').trim().split('\n')
|
||||
pairs.forEach(function(header) {
|
||||
var split = header.trim().split(':')
|
||||
var key = split.shift().trim()
|
||||
var value = split.join(':').trim()
|
||||
head.append(key, value)
|
||||
function parseHeaders(rawHeaders) {
|
||||
var headers = new Headers()
|
||||
rawHeaders.split('\r\n').forEach(function(line) {
|
||||
var parts = line.split(':')
|
||||
var key = parts.shift().trim()
|
||||
if (key) {
|
||||
var value = parts.join(':').trim()
|
||||
headers.append(key, value)
|
||||
}
|
||||
})
|
||||
return head
|
||||
return headers
|
||||
}
|
||||
|
||||
Body.call(Request.prototype)
|
||||
|
|
@ -331,10 +375,10 @@
|
|||
}
|
||||
|
||||
this.type = 'default'
|
||||
this.status = options.status
|
||||
this.status = 'status' in options ? options.status : 200
|
||||
this.ok = this.status >= 200 && this.status < 300
|
||||
this.statusText = options.statusText
|
||||
this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers)
|
||||
this.statusText = 'statusText' in options ? options.statusText : 'OK'
|
||||
this.headers = new Headers(options.headers)
|
||||
this.url = options.url || ''
|
||||
this._initBody(bodyInit)
|
||||
}
|
||||
|
|
@ -372,35 +416,16 @@
|
|||
|
||||
self.fetch = function(input, init) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var request
|
||||
if (Request.prototype.isPrototypeOf(input) && !init) {
|
||||
request = input
|
||||
} else {
|
||||
request = new Request(input, init)
|
||||
}
|
||||
|
||||
var request = new Request(input, init)
|
||||
var xhr = new XMLHttpRequest()
|
||||
|
||||
function responseURL() {
|
||||
if ('responseURL' in xhr) {
|
||||
return xhr.responseURL
|
||||
}
|
||||
|
||||
// Avoid security warnings on getResponseHeader when not allowed by CORS
|
||||
if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
|
||||
return xhr.getResponseHeader('X-Request-URL')
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
xhr.onload = function() {
|
||||
var options = {
|
||||
status: xhr.status,
|
||||
statusText: xhr.statusText,
|
||||
headers: headers(xhr),
|
||||
url: responseURL()
|
||||
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
||||
}
|
||||
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL')
|
||||
var body = 'response' in xhr ? xhr.response : xhr.responseText
|
||||
resolve(new Response(body, options))
|
||||
}
|
||||
|
|
|
|||
2
docs/demo.min.js
vendored
2
docs/demo.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -14,6 +14,10 @@
|
|||
* Will be removed when this part of the API is exposed
|
||||
*/
|
||||
|
||||
/* Utility vars */
|
||||
|
||||
var ArrayProto = [];
|
||||
|
||||
/* Utility functions */
|
||||
|
||||
function escape(value) {
|
||||
|
|
@ -86,11 +90,11 @@
|
|||
}
|
||||
|
||||
function open(node) {
|
||||
function attrStr(a) {
|
||||
function attr_str(a) {
|
||||
return ' ' + a.nodeName + '="' + escape(a.value) + '"';
|
||||
}
|
||||
|
||||
result += '<' + tag(node) + Array.prototype.map.call(node.attributes, attrStr).join('') + '>';
|
||||
result += '<' + tag(node) + ArrayProto.map.call(node.attributes, attr_str).join('') + '>';
|
||||
}
|
||||
|
||||
function close(node) {
|
||||
|
|
@ -103,7 +107,7 @@
|
|||
|
||||
while (original.length || highlighted.length) {
|
||||
var stream = selectStream();
|
||||
result += escape(value.substr(processed, stream[0].offset - processed));
|
||||
result += escape(value.substring(processed, stream[0].offset));
|
||||
processed = stream[0].offset;
|
||||
if (stream === original) {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/styles/github.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/github.min.css">
|
||||
|
||||
<!-- diff2html -->
|
||||
<link rel="stylesheet" type="text/css" href="assets/diff2html.min.css">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/languages/scala.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/languages/scala.min.js"></script>
|
||||
|
||||
<!-- diff2html -->
|
||||
<script type="text/javascript" src="assets/diff2html.min.js"></script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue