ecmascript-6

How to expose a function in svelte that can accept parameters to render?

那年仲夏 提交于 2021-02-10 05:28:06
问题 I'm pretty new to svelte, and for my use case I would like to export the svelte app as a bundle.js which exposes a function let's say startApp(positionInject, appConfiguration) that can accept 2 parameters ( positionInject is the app injection position eg: .app, appConfiguration is the initial configuration of the app to start), based on those parameters svelte app start renders. I am wondering, this is possible in svelte? Appreciate any help. 回答1: Every Svelte component takes a target

How to expose a function in svelte that can accept parameters to render?

我的未来我决定 提交于 2021-02-10 05:25:56
问题 I'm pretty new to svelte, and for my use case I would like to export the svelte app as a bundle.js which exposes a function let's say startApp(positionInject, appConfiguration) that can accept 2 parameters ( positionInject is the app injection position eg: .app, appConfiguration is the initial configuration of the app to start), based on those parameters svelte app start renders. I am wondering, this is possible in svelte? Appreciate any help. 回答1: Every Svelte component takes a target

React does not recognize the `isActive` prop on a DOM element - styled-components

荒凉一梦 提交于 2021-02-10 05:13:16
问题 I have the following svg component where I am passing props. import React from 'react'; export default (props) => ( <svg {...props}> <path d="M11.5 16.45l6.364-6.364" fillRule="evenodd" /> </svg> ); I then have a styled-component that looks like this. const Icon = styled(_Icon)` ${props => props.isActive && css` transform: rotate(-180deg); `}; `; I am seeing the following react error. Warning: React does not recognize the isActive prop on a DOM element. 回答1: I ran into the same issue with

React does not recognize the `isActive` prop on a DOM element - styled-components

末鹿安然 提交于 2021-02-10 05:10:40
问题 I have the following svg component where I am passing props. import React from 'react'; export default (props) => ( <svg {...props}> <path d="M11.5 16.45l6.364-6.364" fillRule="evenodd" /> </svg> ); I then have a styled-component that looks like this. const Icon = styled(_Icon)` ${props => props.isActive && css` transform: rotate(-180deg); `}; `; I am seeing the following react error. Warning: React does not recognize the isActive prop on a DOM element. 回答1: I ran into the same issue with

Edge 15 throws error when using 'for … of' on a NodeList

依然范特西╮ 提交于 2021-02-10 04:02:47
问题 When looking at the ECMAScript compatibility table, it says that Edge 15 and Edge 16 support for ... of loops. However, when I run this code: const list = document.querySelectorAll('[data-test]'); console.log(list); for (const item of list) { console.log(item); } <div data-test></div> <div data-test></div> <div data-test></div> <div data-test></div> <div data-test></div> It works in Chrome and Firefox, but not in Edge. Instead it says: Object doesn't support property or method 'Symbol

Edge 15 throws error when using 'for … of' on a NodeList

旧巷老猫 提交于 2021-02-10 04:00:38
问题 When looking at the ECMAScript compatibility table, it says that Edge 15 and Edge 16 support for ... of loops. However, when I run this code: const list = document.querySelectorAll('[data-test]'); console.log(list); for (const item of list) { console.log(item); } <div data-test></div> <div data-test></div> <div data-test></div> <div data-test></div> <div data-test></div> It works in Chrome and Firefox, but not in Edge. Instead it says: Object doesn't support property or method 'Symbol

Edge 15 throws error when using 'for … of' on a NodeList

你。 提交于 2021-02-10 04:00:29
问题 When looking at the ECMAScript compatibility table, it says that Edge 15 and Edge 16 support for ... of loops. However, when I run this code: const list = document.querySelectorAll('[data-test]'); console.log(list); for (const item of list) { console.log(item); } <div data-test></div> <div data-test></div> <div data-test></div> <div data-test></div> <div data-test></div> It works in Chrome and Firefox, but not in Edge. Instead it says: Object doesn't support property or method 'Symbol

Edge 15 throws error when using 'for … of' on a NodeList

与世无争的帅哥 提交于 2021-02-10 03:59:26
问题 When looking at the ECMAScript compatibility table, it says that Edge 15 and Edge 16 support for ... of loops. However, when I run this code: const list = document.querySelectorAll('[data-test]'); console.log(list); for (const item of list) { console.log(item); } <div data-test></div> <div data-test></div> <div data-test></div> <div data-test></div> <div data-test></div> It works in Chrome and Firefox, but not in Edge. Instead it says: Object doesn't support property or method 'Symbol

ECMAScript 6's function.name property

﹥>﹥吖頭↗ 提交于 2021-02-10 03:21:41
问题 Quick question: what's the correct result for this code: let f = function(){}; let n = f.name; //"" or "f"? According to the compat table, n should have the value "f" . However, the mozilla docs say that it should return an empty string. Which one is correct? 回答1: Since ECMAScript 6 is currently in draft state, the answer below may become outdated sometime in the future. That being said, referencing the spec draft: Anonymous functions objects that do not have a contextual name associated with

switch statement and scopes in ES2015

耗尽温柔 提交于 2021-02-08 23:45:47
问题 Consider this ES2015 module and the behavior when run in node v4.4.5. 'use strict' const outer = 1 switch ('foo') { case 'bar': const heyBar = 'HEY_BAR' break case 'baz': const heyBaz = 'HEY_BAZ' break default: const heyDefault = 'HEY_DEFAULT' } console.log( outer, // 1, makes sense, same top-level scope heyBar, // undefined. huh? I thought switch did NOT create a child scope heyBaz, // undefined. huh? I thought switch did NOT create a child scope heyDefault) // 'HEY_DEFAULT' makes sense This