From 552c62aa56270d39fb9ef828c4363375565bdf77 Mon Sep 17 00:00:00 2001
From: Zirro
Date: Mon, 1 May 2017 20:31:13 +0200
Subject: [PATCH 1/2] Use .querySelector(':checked'), enable several
diff --git a/test/runtime/samples/binding-select-initial-value/main.html b/test/runtime/samples/binding-select-initial-value/main.html
index d7d02194c8da..ea154022401e 100644
--- a/test/runtime/samples/binding-select-initial-value/main.html
+++ b/test/runtime/samples/binding-select-initial-value/main.html
@@ -1,9 +1,9 @@
selected: {{selected}}
-
-
-
+
+
+
selected: {{selected}}
\ No newline at end of file
diff --git a/test/runtime/samples/binding-select-multiple/_config.js b/test/runtime/samples/binding-select-multiple/_config.js
index 89b0da96581f..ec4f3dfe4ec0 100644
--- a/test/runtime/samples/binding-select-multiple/_config.js
+++ b/test/runtime/samples/binding-select-multiple/_config.js
@@ -1,12 +1,12 @@
export default {
- skip: true, // selectedOptions doesn't work in JSDOM???
+ skip: true, // JSDOM
data: {
selected: [ 'two', 'three' ]
},
html: `
-
+
@@ -26,7 +26,7 @@ export default {
assert.deepEqual( component.get( 'selected' ), [ 'three' ] );
assert.htmlEqual( target.innerHTML, `
-
+
@@ -40,7 +40,7 @@ export default {
assert.deepEqual( component.get( 'selected' ), [ 'one', 'three' ] );
assert.htmlEqual( target.innerHTML, `
-
+
@@ -56,7 +56,7 @@ export default {
assert.ok( !options[2].selected );
assert.htmlEqual( target.innerHTML, `
-
+
diff --git a/test/runtime/samples/binding-select/_config.js b/test/runtime/samples/binding-select/_config.js
index 85cf6e9e1a85..7fce00f327ad 100644
--- a/test/runtime/samples/binding-select/_config.js
+++ b/test/runtime/samples/binding-select/_config.js
@@ -1,6 +1,4 @@
export default {
- skip: true, // selectedOptions doesn't work in JSDOM???
-
html: `
selected: one
@@ -13,6 +11,10 @@ export default {
selected: one
`,
+ data: {
+ selected: 'one'
+ },
+
test ( assert, component, target, window ) {
const select = target.querySelector( 'select' );
const options = [ ...target.querySelectorAll( 'option' ) ];
diff --git a/test/runtime/samples/select-change-handler/_config.js b/test/runtime/samples/select-change-handler/_config.js
index 560061a09cab..015c8182b41c 100644
--- a/test/runtime/samples/select-change-handler/_config.js
+++ b/test/runtime/samples/select-change-handler/_config.js
@@ -1,6 +1,4 @@
export default {
- skip: true, // JSDOM
-
data: {
options: [ { id: 'a' }, { id: 'b' }, { id: 'c' } ],
selected: 'b'
diff --git a/test/runtime/samples/select-one-way-bind-object/_config.js b/test/runtime/samples/select-one-way-bind-object/_config.js
index 946eaabcebbe..0d7ddaccad7a 100644
--- a/test/runtime/samples/select-one-way-bind-object/_config.js
+++ b/test/runtime/samples/select-one-way-bind-object/_config.js
@@ -1,8 +1,6 @@
const items = [ {}, {} ];
export default {
- skip: true, // JSDOM quirks
-
'skip-ssr': true,
data: {
From ccafb11c0a34fb7db568672593f1233dcbd8b2dd Mon Sep 17 00:00:00 2001
From: Conduitry
Date: Tue, 2 May 2017 17:47:22 -0400
Subject: [PATCH 2/2] correctly handle when helper functions have been
internally renamed in Svelte bundle (#538)
---
src/generators/dom/index.js | 15 ++++++++-------
src/generators/dom/sharedNames.js | 12 ++++++++++++
2 files changed, 20 insertions(+), 7 deletions(-)
create mode 100644 src/generators/dom/sharedNames.js
diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js
index 173b987aa1b4..cb6d33108739 100644
--- a/src/generators/dom/index.js
+++ b/src/generators/dom/index.js
@@ -6,9 +6,9 @@ import { walk } from 'estree-walker';
import deindent from '../../utils/deindent.js';
import CodeBuilder from '../../utils/CodeBuilder.js';
import visit from './visit.js';
+import { nameMap, sharedMap } from './sharedNames.js';
import Generator from '../Generator.js';
import preprocess from './preprocess.js';
-import * as shared from '../../shared/index.js';
class DomGenerator extends Generator {
constructor ( parsed, source, name, options ) {
@@ -25,7 +25,7 @@ class DomGenerator extends Generator {
}
helper ( name ) {
- if ( this.options.dev && `${name}Dev` in shared ) {
+ if ( this.options.dev && sharedMap.has( `${name}Dev` ) ) {
name = `${name}Dev`;
}
@@ -275,7 +275,7 @@ export default function dom ( parsed, source, options ) {
);
} else {
generator.uses.forEach( key => {
- const str = shared[ key ].toString(); // eslint-disable-line import/namespace
+ const str = sharedMap.get( key );
const code = new MagicString( str );
const fn = parse( str ).body[0];
@@ -286,11 +286,12 @@ export default function dom ( parsed, source, options ) {
if ( node._scope ) scope = node._scope;
if ( node.type === 'Identifier' && isReference( node, parent ) && !scope.has( node.name ) ) {
- if ( node.name in shared ) {
+ if ( nameMap.has( node.name ) ) {
// this helper function depends on another one
- generator.uses.add( node.name );
+ const dependency = nameMap.get( node.name );
+ generator.uses.add( dependency );
- const alias = generator.alias( node.name );
+ const alias = generator.alias( dependency );
if ( alias !== node.name ) code.overwrite( node.start, node.end, alias );
}
}
@@ -301,7 +302,7 @@ export default function dom ( parsed, source, options ) {
}
});
- const alias = generator.alias( fn.id.name );
+ const alias = generator.alias( key );
if ( alias !== fn.id.name ) code.overwrite( fn.id.start, fn.id.end, alias );
builders.main.addBlock( code.toString() );
diff --git a/src/generators/dom/sharedNames.js b/src/generators/dom/sharedNames.js
new file mode 100644
index 000000000000..347969fe5f08
--- /dev/null
+++ b/src/generators/dom/sharedNames.js
@@ -0,0 +1,12 @@
+import * as shared from '../../shared/index.js';
+
+export const nameMap = new Map();
+export const sharedMap = new Map();
+
+Object.keys(shared).forEach( key => {
+ const value = shared[ key ]; // eslint-disable-line import/namespace
+ if ( typeof value === 'function' ) {
+ nameMap.set( value.name, key );
+ }
+ sharedMap.set( key, value.toString() );
+});