]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
style(compiler): changed object-assign to spread (#507)
authorGabriel Loiácono <32134586+loiacon@users.noreply.github.com>
Thu, 28 Nov 2019 15:49:39 +0000 (12:49 -0300)
committerEvan You <yyx990803@gmail.com>
Thu, 28 Nov 2019 15:49:39 +0000 (10:49 -0500)
packages/compiler-core/__tests__/transform.spec.ts
packages/compiler-sfc/src/compileStyle.ts
packages/compiler-sfc/src/stylePreprocessors.ts

index f2660e64f7504a1791fbe85bd5a1ed5525a4f294..baaddd788fee36599e3799f4e6653684b884b282 100644 (file)
@@ -30,7 +30,7 @@ describe('compiler: transform', () => {
     // across calls
     const calls: any[] = []
     const plugin: NodeTransform = (node, context) => {
-      calls.push([node, Object.assign({}, context)])
+      calls.push([node, { ...context }])
     }
 
     transform(ast, {
index 0780cf6940780b541acc7cb1459866622ea76ac1..b61c46f36b630dfea527f70f241fa1b4f5e50bf1 100644 (file)
@@ -132,14 +132,8 @@ function preprocess(
   options: StyleCompileOptions,
   preprocessor: StylePreprocessor
 ): StylePreprocessorResults {
-  return preprocessor.render(
-    options.source,
-    options.map,
-    Object.assign(
-      {
-        filename: options.filename
-      },
-      options.preprocessOptions
-    )
-  )
+  return preprocessor.render(options.source, options.map, {
+    filename: options.filename,
+    ...options.preprocessOptions
+  })
 }
index 5e820ddfe97ebe1fc3b146f07446529b8cff43b4..e391c6b7dca3a240d62e4522a390686e09ef35cc 100644 (file)
@@ -14,12 +14,13 @@ export interface StylePreprocessorResults {
 const scss: StylePreprocessor = {
   render(source, map, options) {
     const nodeSass = require('sass')
-    const finalOptions = Object.assign({}, options, {
+    const finalOptions = {
+      ...options,
       data: source,
       file: options.filename,
       outFile: options.filename,
       sourceMap: !!map
-    })
+    }
 
     try {
       const result = nodeSass.renderSync(finalOptions)
@@ -41,11 +42,10 @@ const scss: StylePreprocessor = {
 
 const sass: StylePreprocessor = {
   render(source, map, options) {
-    return scss.render(
-      source,
-      map,
-      Object.assign({}, options, { indentedSyntax: true })
-    )
+    return scss.render(source, map, {
+      ...options,
+      indentedSyntax: true
+    })
   }
 }
 
@@ -58,7 +58,7 @@ const less: StylePreprocessor = {
     let error: Error | null = null
     nodeLess.render(
       source,
-      Object.assign({}, options, { syncImport: true }),
+      { ...options, syncImport: true },
       (err: Error | null, output: any) => {
         error = err
         result = output