first commit
This commit is contained in:
3
app_vue/node_modules/vue-style-loader/.babelrc
generated
vendored
Normal file
3
app_vue/node_modules/vue-style-loader/.babelrc
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-es2015-modules-commonjs"]
|
||||
}
|
28
app_vue/node_modules/vue-style-loader/.circleci/config.yml
generated
vendored
Normal file
28
app_vue/node_modules/vue-style-loader/.circleci/config.yml
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
# https://circleci.com/docs/2.0/circleci-images/#nodejs
|
||||
- image: circleci/node:6
|
||||
|
||||
working_directory: ~/vue-style-loader
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "package.json" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
|
||||
- run: yarn install
|
||||
|
||||
- save_cache:
|
||||
paths:
|
||||
- node_modules
|
||||
key: v1-dependencies-{{ checksum "package.json" }}
|
||||
|
||||
# run tests!
|
||||
- run: yarn test
|
15
app_vue/node_modules/vue-style-loader/.github/ISSUE_TEMPLATE.md
generated
vendored
Normal file
15
app_vue/node_modules/vue-style-loader/.github/ISSUE_TEMPLATE.md
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!-- Before creating an issue please make sure you are using the latest version of style-loader. -->
|
||||
|
||||
**Do you want to request a *feature* or report a *bug*?**
|
||||
<!-- Please ask questions on StackOverflow or the webpack Gitter (https://gitter.im/webpack/webpack). Questions will be closed. -->
|
||||
|
||||
**What is the current behavior?**
|
||||
|
||||
**If the current behavior is a bug, please provide the steps to reproduce.**
|
||||
<!-- A great way to do this is to provide your configuration via a GitHub gist. -->
|
||||
|
||||
**What is the expected behavior?**
|
||||
|
||||
**If this is a feature request, what is motivation or use case for changing the behavior?**
|
||||
|
||||
**Please mention other relevant information such as your webpack version, Node.js version and Operating System.**
|
18
app_vue/node_modules/vue-style-loader/.github/PULL_REQUEST_TEMPLATE.md
generated
vendored
Normal file
18
app_vue/node_modules/vue-style-loader/.github/PULL_REQUEST_TEMPLATE.md
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. -->
|
||||
|
||||
**What kind of change does this PR introduce?**
|
||||
<!-- E.g. a bugfix, feature, refactoring, build related change, etc… -->
|
||||
|
||||
**Did you add tests for your changes?**
|
||||
|
||||
**If relevant, did you update the README?**
|
||||
|
||||
**Summary**
|
||||
|
||||
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
|
||||
<!-- Try to link to an open issue for more information. -->
|
||||
|
||||
**Does this PR introduce a breaking change?**
|
||||
<!-- If this PR introduces a breaking change, please describe the impact and a migration path for existing applications. -->
|
||||
|
||||
**Other information**
|
86
app_vue/node_modules/vue-style-loader/CHANGELOG.md
generated
vendored
Normal file
86
app_vue/node_modules/vue-style-loader/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
<a name="4.1.3"></a>
|
||||
## [4.1.3](https://github.com/vuejs/vue-style-loader/compare/v4.0.1...v4.1.3) (2021-03-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* also support passed ES modules from `css-loader` in addition to CommonJS format ([#47](https://github.com/vuejs/vue-style-loader/issues/47)) ([8b584bd](https://github.com/vuejs/vue-style-loader/commit/8b584bd))
|
||||
* es module interop in HMR code ([8bc2fe3](https://github.com/vuejs/vue-style-loader/commit/8bc2fe3))
|
||||
* fix addStyleShadow when same style object is inserted multiple times ([12846a6](https://github.com/vuejs/vue-style-loader/commit/12846a6))
|
||||
* fix inconsistent hashes between Windows and POSIX systems ([#28](https://github.com/vuejs/vue-style-loader/issues/28)) ([cf8b6e8](https://github.com/vuejs/vue-style-loader/commit/cf8b6e8))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support vue-loader 15 ([0c7ee9d](https://github.com/vuejs/vue-style-loader/commit/0c7ee9d))
|
||||
|
||||
|
||||
|
||||
<a name="4.1.2"></a>
|
||||
## [4.1.2](https://github.com/vuejs/vue-style-loader/compare/v4.1.1...v4.1.2) (2018-08-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix inconsistent hashes between Windows and POSIX systems ([#28](https://github.com/vuejs/vue-style-loader/issues/28)) ([cf8b6e8](https://github.com/vuejs/vue-style-loader/commit/cf8b6e8))
|
||||
|
||||
|
||||
|
||||
<a name="4.1.1"></a>
|
||||
## [4.1.1](https://github.com/vuejs/vue-style-loader/compare/v4.1.0...v4.1.1) (2018-07-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix addStyleShadow when same style object is inserted multiple times ([12846a6](https://github.com/vuejs/vue-style-loader/commit/12846a6))
|
||||
|
||||
|
||||
|
||||
<a name="4.1.0"></a>
|
||||
# [4.1.0](https://github.com/vuejs/vue-style-loader/compare/v4.0.2...v4.1.0) (2018-03-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support vue-loader 15 ([0c7ee9d](https://github.com/vuejs/vue-style-loader/commit/0c7ee9d))
|
||||
|
||||
|
||||
|
||||
<a name="4.0.2"></a>
|
||||
## [4.0.2](https://github.com/vuejs/vue-style-loader/compare/v4.0.1...v4.0.2) (2018-02-13)
|
||||
|
||||
|
||||
|
||||
<a name="4.0.1"></a>
|
||||
## [4.0.1](https://github.com/vuejs/vue-style-loader/compare/v4.0.0...v4.0.1) (2018-01-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* typo ([00087b7](https://github.com/vuejs/vue-style-loader/commit/00087b7))
|
||||
|
||||
|
||||
|
||||
<a name="4.0.0"></a>
|
||||
# [4.0.0](https://github.com/vuejs/vue-style-loader/compare/v3.1.1...v4.0.0) (2018-01-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* shadowMode ([94737e5](https://github.com/vuejs/vue-style-loader/commit/94737e5))
|
||||
* use ESM for runtime files ([18d0ae4](https://github.com/vuejs/vue-style-loader/commit/18d0ae4))
|
||||
|
||||
|
||||
|
||||
<a name="3.1.1"></a>
|
||||
## [3.1.1](https://github.com/vuejs/vue-style-loader/compare/v3.1.0...v3.1.1) (2018-01-24)
|
||||
|
||||
|
||||
|
||||
<a name="3.1.0"></a>
|
||||
# [3.1.0](https://github.com/vuejs/vue-style-loader/compare/v3.0.3...v3.1.0) (2018-01-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add `ssrId` option for rendering ssr id on client ([5281305](https://github.com/vuejs/vue-style-loader/commit/5281305))
|
20
app_vue/node_modules/vue-style-loader/LICENSE
generated
vendored
Normal file
20
app_vue/node_modules/vue-style-loader/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
47
app_vue/node_modules/vue-style-loader/README.md
generated
vendored
Normal file
47
app_vue/node_modules/vue-style-loader/README.md
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
# vue-style-loader [](https://circleci.com/gh/vuejs/vue-loader/tree/master) [](https://www.npmjs.com/package/vue-style-loader)
|
||||
|
||||
This is a fork based on [style-loader](https://github.com/webpack/style-loader). Similar to `style-loader`, you can chain it after `css-loader` to dynamically inject CSS into the document as style tags. However, since this is included as a dependency and used by default in `vue-loader`, in most cases you don't need to configure this loader yourself.
|
||||
|
||||
## Options
|
||||
|
||||
- **manualInject** (3.1.0+):
|
||||
|
||||
Type: `boolean`. When importing the style from a non-vue-file, by default the style is injected as a side effect of the import. When `manualInject` is true, the imported style object exposes a `__inject__` method, which can then be called manually at appropriate timing. If called on the server, the method expects one argument which is the `ssrContext` to attach styles to.
|
||||
|
||||
``` js
|
||||
import styles from 'styles.scss'
|
||||
|
||||
export default {
|
||||
beforeCreate() { // or create a mixin for this purpose
|
||||
if(styles.__inject__) {
|
||||
styles.__inject__(this.$ssrContext)
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div class={styles.heading}>Hello World</div>
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Note this behavior is enabled automatically when `vue-style-loader` is used on styles imported within a `*.vue` file. The option is only exposed for advanced usage.
|
||||
|
||||
- **ssrId** (3.1.0+):
|
||||
|
||||
Type: `boolean`. Add `data-vue-ssr-id` attribute to injected `<style>` tags even when not in Node.js. This can be used with pre-rendering (instead of SSR) to avoid duplicate style injection on hydration.
|
||||
|
||||
## Differences from `style-loader`
|
||||
|
||||
### Server-Side Rendering Support
|
||||
|
||||
When bundling with `target: 'node'`, the styles in all rendered components are collected and exposed on the Vue render context object as `context.styles`, which you can simply inline into your markup's `<head>`. If you are building a Vue SSR app, you probably should use this loader for CSS imported from JavaScript files too.
|
||||
|
||||
### Misc
|
||||
|
||||
- Does not support url mode and reference counting mode. Also removed `singleton` and `insertAt` query options. It always automatically pick the style insertion mechanism that makes most sense. If you need these capabilities you should probably use the original `style-loader` instead.
|
||||
|
||||
- Fixed the issue that root-relative URLs are interpreted against chrome:// urls and make source map URLs work for injected `<style>` tags in Chrome.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
101
app_vue/node_modules/vue-style-loader/index.js
generated
vendored
Normal file
101
app_vue/node_modules/vue-style-loader/index.js
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
Modified by Evan You @yyx990803
|
||||
*/
|
||||
var loaderUtils = require('loader-utils')
|
||||
var path = require('path')
|
||||
var hash = require('hash-sum')
|
||||
var qs = require('querystring')
|
||||
|
||||
module.exports = function () {}
|
||||
|
||||
module.exports.pitch = function (remainingRequest) {
|
||||
var isServer = this.target === 'node'
|
||||
var isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
||||
var addStylesClientPath = loaderUtils.stringifyRequest(this, '!' + path.join(__dirname, 'lib/addStylesClient.js'))
|
||||
var addStylesServerPath = loaderUtils.stringifyRequest(this, '!' + path.join(__dirname, 'lib/addStylesServer.js'))
|
||||
var addStylesShadowPath = loaderUtils.stringifyRequest(this, '!' + path.join(__dirname, 'lib/addStylesShadow.js'))
|
||||
|
||||
var request = loaderUtils.stringifyRequest(this, '!!' + remainingRequest)
|
||||
var relPath = path.relative(__dirname, this.resourcePath).replace(/\\/g, '/')
|
||||
var id = JSON.stringify(hash(request + relPath))
|
||||
var options = loaderUtils.getOptions(this) || {}
|
||||
|
||||
// direct css import from js --> direct, or manually call `styles.__inject__(ssrContext)` with `manualInject` option
|
||||
// css import from vue file --> component lifecycle linked
|
||||
// style embedded in vue file --> component lifecycle linked
|
||||
var isVue = (
|
||||
/"vue":true/.test(remainingRequest) ||
|
||||
options.manualInject ||
|
||||
qs.parse(this.resourceQuery.slice(1)).vue != null
|
||||
)
|
||||
|
||||
var shared = [
|
||||
'// style-loader: Adds some css to the DOM by adding a <style> tag',
|
||||
'',
|
||||
'// load the styles',
|
||||
'var content = require(' + request + ');',
|
||||
// get default export if list is an ES Module (CSS Loader v4+)
|
||||
"if(content.__esModule) content = content.default;",
|
||||
// content list format is [id, css, media, sourceMap]
|
||||
"if(typeof content === 'string') content = [[module.id, content, '']];",
|
||||
'if(content.locals) module.exports = content.locals;'
|
||||
]
|
||||
|
||||
// shadowMode is enabled in vue-cli with vue build --target web-component.
|
||||
// exposes the same __inject__ method like SSR
|
||||
if (options.shadowMode) {
|
||||
return shared.concat([
|
||||
'// add CSS to Shadow Root',
|
||||
'var add = require(' + addStylesShadowPath + ').default',
|
||||
'module.exports.__inject__ = function (shadowRoot) {',
|
||||
' add(' + id + ', content, shadowRoot)',
|
||||
'};'
|
||||
]).join('\n')
|
||||
} else if (!isServer) {
|
||||
// on the client: dynamic inject + hot-reload
|
||||
var code = [
|
||||
'// add the styles to the DOM',
|
||||
'var add = require(' + addStylesClientPath + ').default',
|
||||
'var update = add(' + id + ', content, ' + isProduction + ', ' + JSON.stringify(options) + ');'
|
||||
]
|
||||
if (!isProduction) {
|
||||
code = code.concat([
|
||||
'// Hot Module Replacement',
|
||||
'if(module.hot) {',
|
||||
' // When the styles change, update the <style> tags',
|
||||
' if(!content.locals) {',
|
||||
' module.hot.accept(' + request + ', function() {',
|
||||
' var newContent = require(' + request + ');',
|
||||
' if(newContent.__esModule) newContent = newContent.default;',
|
||||
" if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];",
|
||||
' update(newContent);',
|
||||
' });',
|
||||
' }',
|
||||
' // When the module is disposed, remove the <style> tags',
|
||||
' module.hot.dispose(function() { update(); });',
|
||||
'}'
|
||||
])
|
||||
}
|
||||
return shared.concat(code).join('\n')
|
||||
} else {
|
||||
// on the server: attach to Vue SSR context
|
||||
if (isVue) {
|
||||
// inside *.vue file: expose a function so it can be called in
|
||||
// component's lifecycle hooks
|
||||
return shared.concat([
|
||||
'// add CSS to SSR context',
|
||||
'var add = require(' + addStylesServerPath + ').default',
|
||||
'module.exports.__inject__ = function (context) {',
|
||||
' add(' + id + ', content, ' + isProduction + ', context)',
|
||||
'};'
|
||||
]).join('\n')
|
||||
} else {
|
||||
// normal import
|
||||
return shared.concat([
|
||||
'require(' + addStylesServerPath + ').default(' + id + ', content, ' + isProduction + ')'
|
||||
]).join('\n')
|
||||
}
|
||||
}
|
||||
}
|
222
app_vue/node_modules/vue-style-loader/lib/addStylesClient.js
generated
vendored
Normal file
222
app_vue/node_modules/vue-style-loader/lib/addStylesClient.js
generated
vendored
Normal file
@ -0,0 +1,222 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
Modified by Evan You @yyx990803
|
||||
*/
|
||||
|
||||
import listToStyles from './listToStyles'
|
||||
|
||||
var hasDocument = typeof document !== 'undefined'
|
||||
|
||||
if (typeof DEBUG !== 'undefined' && DEBUG) {
|
||||
if (!hasDocument) {
|
||||
throw new Error(
|
||||
'vue-style-loader cannot be used in a non-browser environment. ' +
|
||||
"Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."
|
||||
) }
|
||||
}
|
||||
|
||||
/*
|
||||
type StyleObject = {
|
||||
id: number;
|
||||
parts: Array<StyleObjectPart>
|
||||
}
|
||||
|
||||
type StyleObjectPart = {
|
||||
css: string;
|
||||
media: string;
|
||||
sourceMap: ?string
|
||||
}
|
||||
*/
|
||||
|
||||
var stylesInDom = {/*
|
||||
[id: number]: {
|
||||
id: number,
|
||||
refs: number,
|
||||
parts: Array<(obj?: StyleObjectPart) => void>
|
||||
}
|
||||
*/}
|
||||
|
||||
var head = hasDocument && (document.head || document.getElementsByTagName('head')[0])
|
||||
var singletonElement = null
|
||||
var singletonCounter = 0
|
||||
var isProduction = false
|
||||
var noop = function () {}
|
||||
var options = null
|
||||
var ssrIdKey = 'data-vue-ssr-id'
|
||||
|
||||
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
|
||||
// tags it will allow on a page
|
||||
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase())
|
||||
|
||||
export default function addStylesClient (parentId, list, _isProduction, _options) {
|
||||
isProduction = _isProduction
|
||||
|
||||
options = _options || {}
|
||||
|
||||
var styles = listToStyles(parentId, list)
|
||||
addStylesToDom(styles)
|
||||
|
||||
return function update (newList) {
|
||||
var mayRemove = []
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
var item = styles[i]
|
||||
var domStyle = stylesInDom[item.id]
|
||||
domStyle.refs--
|
||||
mayRemove.push(domStyle)
|
||||
}
|
||||
if (newList) {
|
||||
styles = listToStyles(parentId, newList)
|
||||
addStylesToDom(styles)
|
||||
} else {
|
||||
styles = []
|
||||
}
|
||||
for (var i = 0; i < mayRemove.length; i++) {
|
||||
var domStyle = mayRemove[i]
|
||||
if (domStyle.refs === 0) {
|
||||
for (var j = 0; j < domStyle.parts.length; j++) {
|
||||
domStyle.parts[j]()
|
||||
}
|
||||
delete stylesInDom[domStyle.id]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addStylesToDom (styles /* Array<StyleObject> */) {
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
var item = styles[i]
|
||||
var domStyle = stylesInDom[item.id]
|
||||
if (domStyle) {
|
||||
domStyle.refs++
|
||||
for (var j = 0; j < domStyle.parts.length; j++) {
|
||||
domStyle.parts[j](item.parts[j])
|
||||
}
|
||||
for (; j < item.parts.length; j++) {
|
||||
domStyle.parts.push(addStyle(item.parts[j]))
|
||||
}
|
||||
if (domStyle.parts.length > item.parts.length) {
|
||||
domStyle.parts.length = item.parts.length
|
||||
}
|
||||
} else {
|
||||
var parts = []
|
||||
for (var j = 0; j < item.parts.length; j++) {
|
||||
parts.push(addStyle(item.parts[j]))
|
||||
}
|
||||
stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createStyleElement () {
|
||||
var styleElement = document.createElement('style')
|
||||
styleElement.type = 'text/css'
|
||||
head.appendChild(styleElement)
|
||||
return styleElement
|
||||
}
|
||||
|
||||
function addStyle (obj /* StyleObjectPart */) {
|
||||
var update, remove
|
||||
var styleElement = document.querySelector('style[' + ssrIdKey + '~="' + obj.id + '"]')
|
||||
|
||||
if (styleElement) {
|
||||
if (isProduction) {
|
||||
// has SSR styles and in production mode.
|
||||
// simply do nothing.
|
||||
return noop
|
||||
} else {
|
||||
// has SSR styles but in dev mode.
|
||||
// for some reason Chrome can't handle source map in server-rendered
|
||||
// style tags - source maps in <style> only works if the style tag is
|
||||
// created and inserted dynamically. So we remove the server rendered
|
||||
// styles and inject new ones.
|
||||
styleElement.parentNode.removeChild(styleElement)
|
||||
}
|
||||
}
|
||||
|
||||
if (isOldIE) {
|
||||
// use singleton mode for IE9.
|
||||
var styleIndex = singletonCounter++
|
||||
styleElement = singletonElement || (singletonElement = createStyleElement())
|
||||
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false)
|
||||
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true)
|
||||
} else {
|
||||
// use multi-style-tag mode in all other cases
|
||||
styleElement = createStyleElement()
|
||||
update = applyToTag.bind(null, styleElement)
|
||||
remove = function () {
|
||||
styleElement.parentNode.removeChild(styleElement)
|
||||
}
|
||||
}
|
||||
|
||||
update(obj)
|
||||
|
||||
return function updateStyle (newObj /* StyleObjectPart */) {
|
||||
if (newObj) {
|
||||
if (newObj.css === obj.css &&
|
||||
newObj.media === obj.media &&
|
||||
newObj.sourceMap === obj.sourceMap) {
|
||||
return
|
||||
}
|
||||
update(obj = newObj)
|
||||
} else {
|
||||
remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var replaceText = (function () {
|
||||
var textStore = []
|
||||
|
||||
return function (index, replacement) {
|
||||
textStore[index] = replacement
|
||||
return textStore.filter(Boolean).join('\n')
|
||||
}
|
||||
})()
|
||||
|
||||
function applyToSingletonTag (styleElement, index, remove, obj) {
|
||||
var css = remove ? '' : obj.css
|
||||
|
||||
if (styleElement.styleSheet) {
|
||||
styleElement.styleSheet.cssText = replaceText(index, css)
|
||||
} else {
|
||||
var cssNode = document.createTextNode(css)
|
||||
var childNodes = styleElement.childNodes
|
||||
if (childNodes[index]) styleElement.removeChild(childNodes[index])
|
||||
if (childNodes.length) {
|
||||
styleElement.insertBefore(cssNode, childNodes[index])
|
||||
} else {
|
||||
styleElement.appendChild(cssNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyToTag (styleElement, obj) {
|
||||
var css = obj.css
|
||||
var media = obj.media
|
||||
var sourceMap = obj.sourceMap
|
||||
|
||||
if (media) {
|
||||
styleElement.setAttribute('media', media)
|
||||
}
|
||||
if (options.ssrId) {
|
||||
styleElement.setAttribute(ssrIdKey, obj.id)
|
||||
}
|
||||
|
||||
if (sourceMap) {
|
||||
// https://developer.chrome.com/devtools/docs/javascript-debugging
|
||||
// this makes source maps inside style tags work properly in Chrome
|
||||
css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
|
||||
// http://stackoverflow.com/a/26603875
|
||||
css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
|
||||
}
|
||||
|
||||
if (styleElement.styleSheet) {
|
||||
styleElement.styleSheet.cssText = css
|
||||
} else {
|
||||
while (styleElement.firstChild) {
|
||||
styleElement.removeChild(styleElement.firstChild)
|
||||
}
|
||||
styleElement.appendChild(document.createTextNode(css))
|
||||
}
|
||||
}
|
80
app_vue/node_modules/vue-style-loader/lib/addStylesServer.js
generated
vendored
Normal file
80
app_vue/node_modules/vue-style-loader/lib/addStylesServer.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
import listToStyles from './listToStyles'
|
||||
|
||||
export default function addStylesServer (parentId, list, isProduction, context) {
|
||||
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
||||
context = __VUE_SSR_CONTEXT__
|
||||
}
|
||||
if (context) {
|
||||
if (!context.hasOwnProperty('styles')) {
|
||||
Object.defineProperty(context, 'styles', {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return renderStyles(context._styles)
|
||||
}
|
||||
})
|
||||
// expose renderStyles for vue-server-renderer (vuejs/#6353)
|
||||
context._renderStyles = renderStyles
|
||||
}
|
||||
|
||||
var styles = context._styles || (context._styles = {})
|
||||
list = listToStyles(parentId, list)
|
||||
if (isProduction) {
|
||||
addStyleProd(styles, list)
|
||||
} else {
|
||||
addStyleDev(styles, list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In production, render as few style tags as possible.
|
||||
// (mostly because IE9 has a limit on number of style tags)
|
||||
function addStyleProd (styles, list) {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var parts = list[i].parts
|
||||
for (var j = 0; j < parts.length; j++) {
|
||||
var part = parts[j]
|
||||
// group style tags by media types.
|
||||
var id = part.media || 'default'
|
||||
var style = styles[id]
|
||||
if (style) {
|
||||
if (style.ids.indexOf(part.id) < 0) {
|
||||
style.ids.push(part.id)
|
||||
style.css += '\n' + part.css
|
||||
}
|
||||
} else {
|
||||
styles[id] = {
|
||||
ids: [part.id],
|
||||
css: part.css,
|
||||
media: part.media
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In dev we use individual style tag for each module for hot-reload
|
||||
// and source maps.
|
||||
function addStyleDev (styles, list) {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var parts = list[i].parts
|
||||
for (var j = 0; j < parts.length; j++) {
|
||||
var part = parts[j]
|
||||
styles[part.id] = {
|
||||
ids: [part.id],
|
||||
css: part.css,
|
||||
media: part.media
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderStyles (styles) {
|
||||
var css = ''
|
||||
for (var key in styles) {
|
||||
var style = styles[key]
|
||||
css += '<style data-vue-ssr-id="' + style.ids.join(' ') + '"' +
|
||||
(style.media ? ( ' media="' + style.media + '"' ) : '') + '>' +
|
||||
style.css + '</style>'
|
||||
}
|
||||
return css
|
||||
}
|
70
app_vue/node_modules/vue-style-loader/lib/addStylesShadow.js
generated
vendored
Normal file
70
app_vue/node_modules/vue-style-loader/lib/addStylesShadow.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
import listToStyles from './listToStyles'
|
||||
|
||||
export default function addStylesToShadowDOM (parentId, list, shadowRoot) {
|
||||
var styles = listToStyles(parentId, list)
|
||||
addStyles(styles, shadowRoot)
|
||||
}
|
||||
|
||||
/*
|
||||
type StyleObject = {
|
||||
id: number;
|
||||
parts: Array<StyleObjectPart>
|
||||
}
|
||||
|
||||
type StyleObjectPart = {
|
||||
css: string;
|
||||
media: string;
|
||||
sourceMap: ?string
|
||||
}
|
||||
*/
|
||||
|
||||
function addStyles (styles /* Array<StyleObject> */, shadowRoot) {
|
||||
const injectedStyles =
|
||||
shadowRoot._injectedStyles ||
|
||||
(shadowRoot._injectedStyles = {})
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
var item = styles[i]
|
||||
var style = injectedStyles[item.id]
|
||||
if (!style) {
|
||||
for (var j = 0; j < item.parts.length; j++) {
|
||||
addStyle(item.parts[j], shadowRoot)
|
||||
}
|
||||
injectedStyles[item.id] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createStyleElement (shadowRoot) {
|
||||
var styleElement = document.createElement('style')
|
||||
styleElement.type = 'text/css'
|
||||
shadowRoot.appendChild(styleElement)
|
||||
return styleElement
|
||||
}
|
||||
|
||||
function addStyle (obj /* StyleObjectPart */, shadowRoot) {
|
||||
var styleElement = createStyleElement(shadowRoot)
|
||||
var css = obj.css
|
||||
var media = obj.media
|
||||
var sourceMap = obj.sourceMap
|
||||
|
||||
if (media) {
|
||||
styleElement.setAttribute('media', media)
|
||||
}
|
||||
|
||||
if (sourceMap) {
|
||||
// https://developer.chrome.com/devtools/docs/javascript-debugging
|
||||
// this makes source maps inside style tags work properly in Chrome
|
||||
css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
|
||||
// http://stackoverflow.com/a/26603875
|
||||
css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
|
||||
}
|
||||
|
||||
if (styleElement.styleSheet) {
|
||||
styleElement.styleSheet.cssText = css
|
||||
} else {
|
||||
while (styleElement.firstChild) {
|
||||
styleElement.removeChild(styleElement.firstChild)
|
||||
}
|
||||
styleElement.appendChild(document.createTextNode(css))
|
||||
}
|
||||
}
|
27
app_vue/node_modules/vue-style-loader/lib/listToStyles.js
generated
vendored
Normal file
27
app_vue/node_modules/vue-style-loader/lib/listToStyles.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Translates the list format produced by css-loader into something
|
||||
* easier to manipulate.
|
||||
*/
|
||||
export default function listToStyles (parentId, list) {
|
||||
var styles = []
|
||||
var newStyles = {}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var item = list[i]
|
||||
var id = item[0]
|
||||
var css = item[1]
|
||||
var media = item[2]
|
||||
var sourceMap = item[3]
|
||||
var part = {
|
||||
id: parentId + ':' + i,
|
||||
css: css,
|
||||
media: media,
|
||||
sourceMap: sourceMap
|
||||
}
|
||||
if (!newStyles[id]) {
|
||||
styles.push(newStyles[id] = { id: id, parts: [part] })
|
||||
} else {
|
||||
newStyles[id].parts.push(part)
|
||||
}
|
||||
}
|
||||
return styles
|
||||
}
|
13
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/.editorconfig
generated
vendored
Normal file
13
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/.editorconfig
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
1
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/.jshintignore
generated
vendored
Normal file
1
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/.jshintignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
21
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/.jshintrc
generated
vendored
Normal file
21
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"sub": true,
|
||||
"validthis": true,
|
||||
"undef": true,
|
||||
"trailing": true,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"strict": true,
|
||||
"immed": true,
|
||||
"expr": true,
|
||||
"latedef": "nofunc",
|
||||
"quotmark": "single",
|
||||
"indent": 2,
|
||||
"node": true
|
||||
}
|
2
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/.npmignore
generated
vendored
Normal file
2
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/.npmignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
npm-debug.log
|
11
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/changelog.markdown
generated
vendored
Normal file
11
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/changelog.markdown
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# 1.0.2 Quick Sort
|
||||
|
||||
- Sorts object keys so that property order doesn't affect outcome
|
||||
|
||||
# 1.0.1 Perfect Circle
|
||||
|
||||
- Guard against circular references
|
||||
|
||||
# 1.0.0 IPO
|
||||
|
||||
- Initial Public Release
|
58
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/hash-sum.js
generated
vendored
Normal file
58
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/hash-sum.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
function pad (hash, len) {
|
||||
while (hash.length < len) {
|
||||
hash = '0' + hash;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
function fold (hash, text) {
|
||||
var i;
|
||||
var chr;
|
||||
var len;
|
||||
if (text.length === 0) {
|
||||
return hash;
|
||||
}
|
||||
for (i = 0, len = text.length; i < len; i++) {
|
||||
chr = text.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0;
|
||||
}
|
||||
return hash < 0 ? hash * -2 : hash;
|
||||
}
|
||||
|
||||
function foldObject (hash, o, seen) {
|
||||
return Object.keys(o).sort().reduce(foldKey, hash);
|
||||
function foldKey (hash, key) {
|
||||
return foldValue(hash, o[key], key, seen);
|
||||
}
|
||||
}
|
||||
|
||||
function foldValue (input, value, key, seen) {
|
||||
var hash = fold(fold(fold(input, key), toString(value)), typeof value);
|
||||
if (value === null) {
|
||||
return fold(hash, 'null');
|
||||
}
|
||||
if (value === undefined) {
|
||||
return fold(hash, 'undefined');
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
if (seen.indexOf(value) !== -1) {
|
||||
return fold(hash, '[Circular]' + key);
|
||||
}
|
||||
seen.push(value);
|
||||
return foldObject(hash, value, seen);
|
||||
}
|
||||
return fold(hash, value.toString());
|
||||
}
|
||||
|
||||
function toString (o) {
|
||||
return Object.prototype.toString.call(o);
|
||||
}
|
||||
|
||||
function sum (o) {
|
||||
return pad(foldValue(0, o, '', []).toString(16), 8);
|
||||
}
|
||||
|
||||
module.exports = sum;
|
20
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/license
generated
vendored
Normal file
20
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/license
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2014 Nicolas Bevacqua
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/package.json
generated
vendored
Normal file
27
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/package.json
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "hash-sum",
|
||||
"description": "Blazing fast unique hash generator",
|
||||
"version": "1.0.2",
|
||||
"homepage": "https://github.com/bevacqua/hash-sum",
|
||||
"authors": [
|
||||
"Nicolas Bevacqua <nicolasbevacqua@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/bevacqua/hash-sum.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/bevacqua/hash-sum/issues"
|
||||
},
|
||||
"main": "hash-sum.js",
|
||||
"scripts": {
|
||||
"test": "jshint . && tape test.js"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"jshint": "2.5.0",
|
||||
"jshint-stylish": "0.2.0",
|
||||
"tape": "3.0.3"
|
||||
}
|
||||
}
|
67
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/readme.md
generated
vendored
Normal file
67
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/readme.md
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
# hash-sum
|
||||
|
||||
> blazing fast unique hash generator
|
||||
|
||||
# install
|
||||
|
||||
```shell
|
||||
npm i hash-sum -S
|
||||
```
|
||||
|
||||
# features
|
||||
|
||||
- no dependencies
|
||||
- minimal footprint
|
||||
- works in all of node.js, io.js, and the browser
|
||||
- hashes functions based on their source code
|
||||
- produces different hashes for different object types
|
||||
- support for circular references in objects
|
||||
- ignores property assignment order
|
||||
|
||||
# `sum(value)`
|
||||
|
||||
yields a four-byte hexadecimal hash based off of `value`.
|
||||
|
||||
```
|
||||
# creates unique hashes
|
||||
creates unique hashes
|
||||
4d237d49 from: [ 0, 1, 2, 3 ]
|
||||
766ec173 from: { url: 12 }
|
||||
2f473108 from: { headers: 12 }
|
||||
23308836 from: { headers: 122 }
|
||||
062bce44 from: { headers: '122' }
|
||||
acb9f66e from: { headers: { accept: 'text/plain' } }
|
||||
1c365a2d from: { payload: [ 0, 1, 2, 3 ], headers: [ { a: 'b' } ] }
|
||||
7319ae9d from: { a: [Function] }
|
||||
8a3a0e86 from: { b: [Function] }
|
||||
b6d7f5d4 from: { b: [Function] }
|
||||
6c95fc65 from: function () {}
|
||||
2941766e from: function (a) {}
|
||||
294f8def from: function (b) {}
|
||||
2d9c0cb8 from: function (a) { return a;}
|
||||
ed5c63fc from: function (a) {return a;}
|
||||
bba68bf6 from: ''
|
||||
2d27667d from: 'null'
|
||||
774b96ed from: 'false'
|
||||
2d2a1684 from: 'true'
|
||||
8daa1a0c from: '0'
|
||||
8daa1a0a from: '1'
|
||||
e38f07cc from: 'void 0'
|
||||
6037ea1a from: 'undefined'
|
||||
9b7df12e from: null
|
||||
3c206f76 from: false
|
||||
01e34ba8 from: true
|
||||
1a96284a from: 0
|
||||
1a96284b from: 1
|
||||
29172c1a from: undefined
|
||||
4505230f from: {}
|
||||
3718c6e8 from: { a: {}, b: {} }
|
||||
5d844489 from: []
|
||||
938eaaf0 from: Tue Jul 14 2015 15:35:36 GMT-0300 (ART)
|
||||
dfe5fb2e from: global
|
||||
ok 1 should be equal
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
61
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/test.js
generated
vendored
Normal file
61
app_vue/node_modules/vue-style-loader/node_modules/hash-sum/test.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
var test = require('tape');
|
||||
var sum = require('./');
|
||||
|
||||
test('creates unique hashes', function (t) {
|
||||
var results = [];
|
||||
sub([0,1,2,3]);
|
||||
sub({url:12});
|
||||
sub({headers:12});
|
||||
sub({headers:122});
|
||||
sub({headers:'122'});
|
||||
sub({headers:{accept:'text/plain'}});
|
||||
sub({payload:[0,1,2,3],headers:[{a:'b'}]});
|
||||
sub({a:function () {}});
|
||||
sub({b:function () {}});
|
||||
sub({b:function (a) {}});
|
||||
sub(function () {});
|
||||
sub(function (a) {});
|
||||
sub(function (b) {});
|
||||
sub(function (a) { return a;});
|
||||
sub(function (a) {return a;});
|
||||
sub('');
|
||||
sub('null');
|
||||
sub('false');
|
||||
sub('true');
|
||||
sub('0');
|
||||
sub('1');
|
||||
sub('void 0');
|
||||
sub('undefined');
|
||||
sub(null);
|
||||
sub(false);
|
||||
sub(true);
|
||||
sub(0);
|
||||
sub(1);
|
||||
sub(void 0);
|
||||
sub({});
|
||||
sub({a:{},b:{}});
|
||||
sub([]);
|
||||
sub(new Date());
|
||||
sub(global, 'global');
|
||||
t.equal(results.length, _.uniq(results).length);
|
||||
t.end();
|
||||
|
||||
function sub (value, name) {
|
||||
var hash = sum(value);
|
||||
results.push(hash);
|
||||
console.log('%s from:', hash, name || value);
|
||||
}
|
||||
});
|
||||
|
||||
test('hashes clash if same properties', function (t) {
|
||||
equals({a:'1'},{a:'1'});
|
||||
equals({a:'1',b:1},{b:1,a:'1'});
|
||||
t.end();
|
||||
|
||||
function equals (a, b) {
|
||||
t.equal(sum(a), sum(b));
|
||||
}
|
||||
});
|
26
app_vue/node_modules/vue-style-loader/package.json
generated
vendored
Normal file
26
app_vue/node_modules/vue-style-loader/package.json
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "vue-style-loader",
|
||||
"version": "4.1.3",
|
||||
"author": "Evan You",
|
||||
"description": "Vue.js style loader module for webpack",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:vuejs/vue-style-loader.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"prepublishOnly": "conventional-changelog -p angular -r 2 -i CHANGELOG.md -s"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"hash-sum": "^1.0.2",
|
||||
"loader-utils": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-jest": "^22.1.0",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
|
||||
"conventional-changelog-cli": "^2.0.1",
|
||||
"jest": "^22.1.4"
|
||||
}
|
||||
}
|
94
app_vue/node_modules/vue-style-loader/test/test.js
generated
vendored
Normal file
94
app_vue/node_modules/vue-style-loader/test/test.js
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
import addStylesClient from '../lib/addStylesClient'
|
||||
import addStylesServer from '../lib/addStylesServer'
|
||||
|
||||
const mockedList = [
|
||||
[1, 'h1 { color: red; }', ''],
|
||||
[1, 'p { color: green; }', ''],
|
||||
[2, 'span { color: blue; }', ''],
|
||||
[2, 'span { color: blue; }', 'print']
|
||||
]
|
||||
|
||||
test('addStylesClient (dev)', () => {
|
||||
const update = addStylesClient('foo', mockedList, false)
|
||||
assertStylesMatch(mockedList)
|
||||
const mockedList2 = mockedList.slice(1, 3)
|
||||
update(mockedList2)
|
||||
assertStylesMatch(mockedList2)
|
||||
update()
|
||||
expect(document.querySelectorAll('style').length).toBe(0)
|
||||
})
|
||||
|
||||
test('addStylesClient (prod)', () => {
|
||||
const update = addStylesClient('foo', mockedList, true)
|
||||
assertStylesMatch(mockedList)
|
||||
const mockedList2 = mockedList.slice(2)
|
||||
update(mockedList2)
|
||||
assertStylesMatch(mockedList2)
|
||||
update()
|
||||
expect(document.querySelectorAll('style').length).toBe(0)
|
||||
})
|
||||
|
||||
test('addStylesClient (dev + ssr)', () => {
|
||||
mockSSRTags(mockedList, 'foo')
|
||||
const update = addStylesClient('foo', mockedList, false)
|
||||
assertStylesMatch(mockedList)
|
||||
update()
|
||||
expect(document.querySelectorAll('style').length).toBe(0)
|
||||
})
|
||||
|
||||
test('addStylesClient (prod + ssr)', () => {
|
||||
mockProdSSRTags(mockedList, 'foo')
|
||||
const update = addStylesClient('foo', mockedList, true)
|
||||
expect(document.querySelectorAll('style').length).toBe(1)
|
||||
})
|
||||
|
||||
test('addStylesServer (dev)', () => {
|
||||
const context = global.__VUE_SSR_CONTEXT__ = {}
|
||||
addStylesServer('foo', mockedList, false)
|
||||
expect(context.styles).toBe(
|
||||
`<style data-vue-ssr-id="foo:0">h1 { color: red; }</style>` +
|
||||
`<style data-vue-ssr-id="foo:1">p { color: green; }</style>` +
|
||||
`<style data-vue-ssr-id="foo:2">span { color: blue; }</style>` +
|
||||
`<style data-vue-ssr-id="foo:3" media="print">span { color: blue; }</style>`
|
||||
)
|
||||
})
|
||||
|
||||
test('addStylesServer (prod)', () => {
|
||||
const context = global.__VUE_SSR_CONTEXT__ = {}
|
||||
addStylesServer('foo', mockedList, true)
|
||||
expect(context.styles).toBe(
|
||||
`<style data-vue-ssr-id="foo:0 foo:1 foo:2">` +
|
||||
`h1 { color: red; }\np { color: green; }\nspan { color: blue; }` +
|
||||
`</style>` +
|
||||
`<style data-vue-ssr-id="foo:3" media="print">span { color: blue; }</style>`
|
||||
)
|
||||
})
|
||||
|
||||
// --- helpers ---
|
||||
|
||||
function assertStylesMatch (list) {
|
||||
const styles = document.querySelectorAll('style')
|
||||
expect(styles.length).toBe(list.length)
|
||||
;[].forEach.call(styles, (style, i) => {
|
||||
expect(style.textContent.indexOf(list[i][1]) > -1).toBe(true)
|
||||
})
|
||||
}
|
||||
|
||||
function mockSSRTags (list, parentId) {
|
||||
list.forEach((item, i) => {
|
||||
const style = document.createElement('style')
|
||||
style.setAttribute('data-vue-ssr-id', `${parentId}:${i}`)
|
||||
style.textContent = item[1]
|
||||
if (item[2]) {
|
||||
style.setAttribute('media', item[2])
|
||||
}
|
||||
document.head.appendChild(style)
|
||||
})
|
||||
}
|
||||
|
||||
function mockProdSSRTags (list, parentId) {
|
||||
const style = document.createElement('style')
|
||||
style.setAttribute('data-vue-ssr-id', list.map((item, i) => `${parentId}:${i}`).join(' '))
|
||||
style.textContent = list.map(item => item[1]).join('\n')
|
||||
document.head.appendChild(style)
|
||||
}
|
Reference in New Issue
Block a user