profile
viewpoint
狼叔 i5ting alibaba china beijing http://i5ting.com 少抱怨,多思考,未来更美好

hiproxy/hiproxy 630

🛠 hiproxy is a lightweight proxy tool for Front-End developers based on Node.js that supports an NGINX-like configuration. 🔥

17koa/runkoa 98

DEPRECATED runkoa:使用koa1和koa2的时候,不用在意babel的细节,无论哪种写法(common, generator, async)都完美支持

dev-reading/practical-node-tutorial 87

实用Node.js,简单粗暴,新手学习的最短曲线

17koa/base2-core 19

高度可配置的带有应用生命周期管控的 nodejs web 微框架(同时支持express和koa)

andy0323/ipa-build 13

ipa-build node 它是一款iOS的打包工具. 轻松完成ipa打包

fundon/jstips 13

This is about one JS tip every day!

17koa/node4koa 8

node4koa

bigviewjs/bigview.js 5

结合bigview Node.js模块使用的浏览器端实现

issue commentethereum/solidity

Wrong evaluation order of arguments to parent constructors

Here you need to evaluate Foo(value + getValue()) before finishing constructing Foo, which then depends on already having visited Bar(Bar.g()).

I don't think this code should be allowed. It doesn't make sense to call a function if its defining context hasn't been initialized.

Here's a similar example in JavaScript, which is disallowed:

class A {
  constructor(value) {
    this.value = value;
  }

  getValue() {
    return this.value;
  }
}

class B extends A {
  constructor() {
    super(this.getValue()); // ReferenceError: Must call super constructor
                            // in derived class before accessing 'this'
  }
}

new B();

frangio

comment created time in a few seconds

push eventgrpc/grpc

Esun Kim

commit sha 351e2cb83b95444b0fa6f6ccebf6031030ed3558

Enable google-explicit-constructor

view details

Esun Kim

commit sha 53ab235fb89d0d87161b45391485d4eab58dd4c8

Fix google-explicit-constructor

view details

Esun Kim

commit sha d0f0aac905c7e9060b14a3ef438f991077376ac2

Merge pull request #24873 from veblush/tidy-google-explicit-constructor [Clang-Tidy] google-explicit-constructor

view details

push time in 2 minutes

PR merged grpc/grpc

[Clang-Tidy] google-explicit-constructor kind/internal cleanup lang/c++ lang/core release notes: no

https://clang.llvm.org/extra/clang-tidy/checks/google-explicit-constructor.html

Adding explicit to ctors using automatic fix except Json, RefCountedPtr, and WeakRefCountedPtr which are designed to benefit from using the implicit constructor.

+157 -115

2 comments

62 changed files

veblush

pr closed time in 2 minutes

issue commentcnodejs/nodeclub

网站访问不了,下一步的打算是什么,是关停还是正在寻找办法?

你好,我打算重新搭建中文社区,相应的服务器资源已经有了。请问是否可以提供 帖子数据?

GO-DIE

comment created time in 2 minutes

IssuesEvent

issue commentmicrosoft/vscode

Find with Regex Lookbehind

Actually nevermind, I still see errors in the developer tools:

Repro

  1. On windows in the VS Code Codebase
  2. Do a workspace search for (?<=\n)\w
  3. Open Developer tools

I see lots of errors that look like:

[IPC Library: Search] Uncaught Exception:  TypeError: Cannot read property 'startLineNumber' of undefined
    at c:\Users\matb\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\search\node\searchApp.js:172:869
    at new t.TextSearchMatch (c:\Users\matb\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\search\node\searchApp.js:172:966)
    at Object.t.createTextSearchResult (c:\Users\matb\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\search\node\searchApp.js:183:949)
    at y.createTextSearchMatch (c:\Users\matb\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\search\node\searchApp.js:210:624)
    at y.handleLine (c:\Users\matb\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\search\node\searchApp.js:209:618)
    at y.handleDecodedData (c:\Users\matb\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\search\node\searchApp.js:209:312)
    at y.handleData (c:\Users\matb\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\search\node\searchApp.js:209:133)
    at Socket.<anonymous> (c:\Users\matb\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\search\node\searchApp.js:208:77)
    at Socket.emit (events.js:228:7)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:181:23)
t.log @ workbench.desktop.main.js:sourcemap:310

There errors are not shown to the user so I was not aware they were happening until checking the dev tools

merkuriy

comment created time in 2 minutes

issue commentmicrosoft/vscode

[ejs] <%= %> in .ejs file marked as wrong but correct

thanks a lot, guys I did fix the problem. @aeschli

omginput

comment created time in 4 minutes

issue openedJermolene/TiddlyWiki5

[IDEA] reduce operator: default value from second operand.

Use an optional second operand for the default value for reduce, so that variables and references can be used to assign the default.

@Jermolene if we want to support this we should make the change before 5.1.23 goes live.

created time in 7 minutes

Pull request review commentenvoyproxy/envoy

buffer: Optimize memory layout for buffer slices so it is better aligned with the 16KB transport socket read size

 static void appendSlice(Buffer::Instance& buffer, uint32_t size) {   buffer.commit(&slice, 1); } +static void addTenFullSizeSlices(Buffer::Instance& buffer) {

Attempted to address the naming issue.

antoniovicente

comment created time in 7 minutes

startednlkl/Optional

started time in 7 minutes

issue commentmicrosoft/vscode

Find with Regex Lookbehind

@roblourens I verified this search no longer triggers an error. However on windows I only see a workspace search for (?<=\n)\w returning results from open files. This may be expected but it seemed odd

merkuriy

comment created time in 8 minutes

issue commentmicrosoft/vscode

Commenting is not working properly

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

alakcreature

comment created time in 8 minutes

pull request commenth2o/h2o

avoiding a memcpy in find_hostconf

Thank you for looking into the CI issue. I tend to think that it is a glitch unrelated to this PR. Will merge soon regardless of that failure.

robguima

comment created time in 9 minutes

issue commentmicrosoft/vscode

Commenting is not working properly

/needsMoreInfo Does this also happen after you run the command to reload with all extensions disabled? If not, it's being caused by one of your extensions and needs to be reported to the extension's repo.

alakcreature

comment created time in 9 minutes

issue commentethereum/solidity

Wrong evaluation order of arguments to parent constructors

However, all state variables are initialized as 0 before the rules 1) and 2) above

Sure, we're not talking about uninitialized memory like on a regular computer program. Of course that would be a more serious issue. What I'm pointing out is an issue of language semantics.

A contract assigns a state variable in the constructor then exposes that state variable through a getter function: would anyone expect the getter to ever return anything other than the value assigned in the constructor? I don't think so. The intuition is that the constructor runs before anything else does. And it goes beyond reading uninitialized values, constructors can establish invariants that are assumed to hold for the execution of other functions in the contract. This evaluation order is violating that assumption, which is why I see this as a pretty serious issue.

frangio

comment created time in 9 minutes

push eventPolymer/lit-html

Kevin Schaaf

commit sha 823fe9ce078aeb8acce104d16e8fe5e3adfb9661

Move comment

view details

push time in 10 minutes

Pull request review commentgin-gonic/gin

some loop don't need to transfer to bytes slice and some use the zero…

 walk: // Outer loop for walking the tree 				if rb[0] != 0 { 					// Old rune not finished 					idxc := rb[0]-					for i, c := range []byte(n.indices) {+					for i, c := range bytesconv.StringToBytes(n.indices) {

thanks. using local var save the result of StringToBytes?

that kind of change is not necessary.

mask-pp

comment created time in 11 minutes

issue closedmicrosoft/vscode

Typo in settings s/weather/whether/

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. --> <!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: https://code.visualstudio.com/insiders/ -->

<!-- Use Help > Report Issue to prefill these. -->

  • VSCode Version:Version: 1.51.1 (user setup) Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f Date: 2020-11-10T23:34:32.027Z Electron: 9.3.3 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.17134
  • OS Version:10.0.17134 N/A Build 17134

Steps to Reproduce:

1.CTRL+, 2.search for weather

Editor › Smart Select: Select Leading And Trailing Whitespace Weather leading and trailing whitespace should always be selected.

<!-- Launch with code --disable-extensions to check. --> Does this issue occur when all extensions are disabled?: Yes

closed time in 12 minutes

aaegic

issue commentmicrosoft/vscode

Typo in settings s/weather/whether/

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!

aaegic

comment created time in 12 minutes

issue closedEbookFoundation/free-programming-books

Site is difficult to follow for a newbie, especially for someone looking for resources other than books

Your site has wonderful resources, and I really appreciate everything that has gone into it. Unfortunately, I found the organization more difficult to follow than it needs to be. I did make one PR, but don't have time to make others, so I am leaving these suggestions, to use or ignore as you see fit.

  1. It is not clear whether the site is for "books" or "resources". I vote for making it "resources." Then the sections would be Introduction, Books, Online Courses, Interactive Programming Resources, Problem Sets, Podcast - Screencast, Programming Playgrounds (though could that be combined with "Interactive Programming Resources"?)

  2. At the very least, "View the English list" should say "View the English list of books".

  3. The pages for "Online Courses", "Interactive Programming Resources", "Programming Playgrounds" are just labeled "Index" so it is impossible to know what you are looking at. They should be titled "Index of Programming Playgrounds", e.g.

  4. My PR was about online programming playgrounds, and @eshellman raised the question of whether frameworks (React and Angular) should be listed separately, or under JavaScript as is done in books. I agree that it would be good to organize all the pages the same way, and it probably makes sense to list frameworks under languages. However, it would be good to indent the frameworks on the full list, rather than have them as top-level entries the way they are here. I understand that it may not be easy to do that in Jekyll. I see that the titles are <h3>s. Maybe the subsection titles could be <h4>s with some css to indent them. It would be OK to just indent the subheader, if it turns out not to be easy to indent lists under subheader.

Thanks for keeping up such a great resource, sorry I don't have time to do the PRs myself!

closed time in 12 minutes

natkuhn

issue commentmicrosoft/vscode

Typo in settings s/weather/whether/

/duplicate of #110661 and fixed in upcoming release, due out next week.

aaegic

comment created time in 12 minutes

Pull request review commentPolymer/lit-html

[lit-html] Add DisconnectableDirective implementation

 export function* renderTemplateResult(           // eslint-disable-next-line @typescript-eslint/no-explicit-any           (null as any) as HTMLElement,           op.name,-          statics+          statics,+          undefined

Done

kevinpschaaf

comment created time in 13 minutes

Pull request review commentPolymer/lit-html

[lit-html] Add DisconnectableDirective implementation

 export class AttributePart {     element: HTMLElement,     name: string,     strings: ReadonlyArray<string>,+    parent: DisconnectableParent | undefined,

Done

kevinpschaaf

comment created time in 13 minutes

Pull request review commentPolymer/lit-html

[lit-html] Add DisconnectableDirective implementation

+/**+ * @license+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.+ * This code may only be used under the BSD style license found at+ * http://polymer.github.io/LICENSE.txt+ * The complete set of authors may be found at+ * http://polymer.github.io/AUTHORS.txt+ * The complete set of contributors may be found at+ * http://polymer.github.io/CONTRIBUTORS.txt+ * Code distributed by Google as part of the polymer project is also+ * subject to an additional IP rights grant found at+ * http://polymer.github.io/PATENTS.txt+ */++import {+  Directive,+  PartInfo,+  NodePart,+  NODE_PART,+  DisconnectableParent,+} from './lit-html.js';+export {directive} from './lit-html.js';++/**+ * Recursively walks down the tree of Parts/TemplateInstances/Directives to set+ * the connected state of directives and run `disconnectedCallback`/+ * `reconnectedCallback`s.+ */+const setChildrenConnected = (+  parent: DisconnectableParent,+  isConnected: boolean,+  shouldRemoveFromParent = false+) => {+  const children = parent._$disconnetableChildren;+  if (children !== undefined) {+    for (const child of children) {+      if ((child as Directive)._$setDirectiveConnected) {+        // Disconnect Directive (and any directive children)+        (child as DisconnectableDirective)._$setDirectiveConnected(+          isConnected,+          false+        );+      } else {+        // Disconnect Part/TemplateInstance+        setChildrenConnected(child, isConnected);+      }+    }+    if (shouldRemoveFromParent) {+      // When a NodePart is being cleared, this method will be called with its+      // value (a TemplateInstance or iterable of NodeParts) and+      // shouldRemoveFromParent==true. In that case, we will delete the value+      // (`parent` in this function) from the NodePart, and then the NodePart+      // will call `removeFromParentIfEmpty` to determine whether to remove the+      // NodePart from _its_ parent.+      parent._$parent?._$disconnetableChildren!.delete(parent);+    }+  }+};++/**+ * Removes the given child from its parent list of disconnectable children if+ * its own list is empty, and so forth up the tree when that causes subsequent+ * parent lists to become empty.+ */+const removeFromParentIfEmpty = (child: DisconnectableParent) => {+  for (+    let parent = child._$parent, children = child._$disconnetableChildren;+    children !== undefined && children.size === 0;+    child = parent, parent = child._$parent+  ) {+    child._$disconnetableChildren = undefined;+    if (parent !== undefined) {+      children = parent._$disconnetableChildren!;+      children.delete(child);+    } else {+      break;+    }+  }+};++/**+ * Sets the connected state on any directives contained within the committed+ * value of this part (i.e. within a TemplateInstance or iterable of NodeParts)+ * and runs their `disconnectedCallback`/`reconnectedCallback`s, as well as+ * within any directives stored on the NodePart (when `valueOnly` is false).+ *+ * `valueOnly` should be passed as `true` on a top-level part that is clearing+ * itself, and not as a result of recursively disconnecting directives as part+ * of a `clear` operation higher up the tree. This both ensures that any+ * directive on this NodePart that produced a value that caused the clear+ * operation is not disconnected, and also serves as a performance optimization+ * to avoid needless bookkeeping when a subtree is going away; when clearing a+ * subtree, only the top-most part need to remove itself from the parent.+ *+ * Note, this method will be patched onto NodePart instances and called from the+ * core code when parts are cleared or the connection state is changed by the+ * user.+ */+function setNodePartConnected(+  this: NodePart,+  isConnected: boolean,+  valueOnly = false,

Done: isClearingValue

kevinpschaaf

comment created time in 13 minutes

Pull request review commentPolymer/lit-html

[lit-html] Add DisconnectableDirective implementation

+/**+ * @license+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.+ * This code may only be used under the BSD style license found at+ * http://polymer.github.io/LICENSE.txt+ * The complete set of authors may be found at+ * http://polymer.github.io/AUTHORS.txt+ * The complete set of contributors may be found at+ * http://polymer.github.io/CONTRIBUTORS.txt+ * Code distributed by Google as part of the polymer project is also+ * subject to an additional IP rights grant found at+ * http://polymer.github.io/PATENTS.txt+ */++import {+  Directive,+  PartInfo,+  NodePart,+  NODE_PART,+  DisconnectableParent,+} from './lit-html.js';+export {directive} from './lit-html.js';++/**+ * Recursively walks down the tree of Parts/TemplateInstances/Directives to set+ * the connected state of directives and run `disconnectedCallback`/+ * `reconnectedCallback`s.+ */+const setChildrenConnected = (+  parent: DisconnectableParent,+  isConnected: boolean,+  shouldRemoveFromParent = false+) => {+  const children = parent._$disconnetableChildren;+  if (children !== undefined) {+    for (const child of children) {+      if ((child as Directive)._$setDirectiveConnected) {+        // Disconnect Directive (and any directive children)+        (child as DisconnectableDirective)._$setDirectiveConnected(+          isConnected,+          false+        );+      } else {+        // Disconnect Part/TemplateInstance+        setChildrenConnected(child, isConnected);+      }+    }+    if (shouldRemoveFromParent) {+      // When a NodePart is being cleared, this method will be called with its+      // value (a TemplateInstance or iterable of NodeParts) and+      // shouldRemoveFromParent==true. In that case, we will delete the value+      // (`parent` in this function) from the NodePart, and then the NodePart+      // will call `removeFromParentIfEmpty` to determine whether to remove the+      // NodePart from _its_ parent.+      parent._$parent?._$disconnetableChildren!.delete(parent);

Done, good suggestion

kevinpschaaf

comment created time in 13 minutes

Pull request review commentPolymer/lit-html

[lit-html] Add DisconnectableDirective implementation

 and this project adheres to [Semantic Versioning](http://semver.org/). <!-- ### Fixed --> <!-- ### Removed --> +<!-- ## [X.Y.Z] - YYYY-MM-DD -->++## Unreleased++<!-- ### Changed -->++### Added++- `render` now returns the `NodePart` that was created/updated by `render`.++- Added `DisconnectableDirective`, which is a `Directive` subclass whose+  `disconnectedCallback` will be called when the part containing the directive

Correct, clarified.

kevinpschaaf

comment created time in 13 minutes

issue closedEbookFoundation/free-programming-books

Broken Russian links - HELP REQUESTED

Below is a list of failing links in our Russian lists You can help improve this repo by resolving the problems.

A failing link may be a website or resource that has disappeared. You can submit a PR

  • removing the link (maybe the resource is obsolete.)
  • correcting the link (sometimes things move)
  • replacing the link (make sure the link is authorized, or the resource is open-licensed). Often a link to internet archive's wayback machine is useful.

Sometimes a link is only temporarily failing, or the site blocks link-checkers. If that's the case, leave a note on this issue.

In your PR, reference this issue.

Thanks for your help!

free-programming-books-ru.md

  • [ ] 404 Not Found https://ru.wikibooks.org/wiki/%D0
  • [ ] 404 Not Found https://younglinux.info/%D1
  • [ ] 404 Not Found https://ru.wikibooks.org/wiki/%D0
  • [ ] 404 Not Found http://ru.wikibooks.org/wiki/%D0
  • [ ] 404 Not Found https://ru.wikibooks.org/wiki/%D0
  • [ ] 500 Can't connect to railstutorial.ru:80 (Name or service not known) http://railstutorial.ru/chapters/4_0/beginning
  • [ ] 404 Not Found https://younglinux.info/linuxintro

closed time in 13 minutes

eshellman

Pull request review commentPolymer/lit-html

[lit-html] Add DisconnectableDirective implementation

 import {assert} from '@esm-bundle/chai';       assert.equal(a.shadowRoot, undefined);     }   );++  suite('disconnection handling', () => {+    let host: Host;+    const log: string[] = [];++    const d = directive(+      class extends DisconnectableDirective {+        id!: unknown;+        render(id: unknown) {+          log.push(`render-${id}`);+          return (this.id = id);+        }+        disconnectedCallback() {+          log.push(`disconnect-${this.id}`);+        }+        reconnectedCallback() {+          log.push(`reconnect-${this.id}`);+        }+      }+    );++    class Child extends LitElement {+      static properties = {+        attr: {type: String},+        prop: {type: String},+      };+      attr = 'default';+      prop = 'default';+      render() {+        return html`<div attr=${d('child-attr')} .prop=${d('child-prop')}>+          ${d('child-node')}+        </div>`;+      }+      get child() {+        return this.shadowRoot!.firstElementChild as Child;+      }+    }+    customElements.define('disc-child', Child);++    class Host extends LitElement {+      render() {+        return html`<disc-child attr=${d('host-attr')} .prop=${d('host-prop')}+          >${d('host-node')}</disc-child+        >`;+      }+      get child() {+        return this.shadowRoot!.firstElementChild as Child;+      }+    }+    customElements.define('disc-host', Host);++    const assertRendering = (host: Host) => {+      let child = host.child;+      assert.equal(child.getAttribute('attr'), 'host-attr');+      assert.equal(child.prop, 'host-prop');+      assert.equal(child.textContent?.trim(), 'host-node');+      child = child.child;+      assert.equal(child.getAttribute('attr'), 'child-attr');+      assert.equal(child.prop, 'child-prop');+      assert.equal(child.textContent?.trim(), 'child-node');+    };++    setup(() => {+      log.length = 0;+      host = new Host();+    });++    teardown(() => {+      if (host.isConnected) {+        container.removeChild(host);+      }+    });++    test('directives render on connection', async () => {+      container.appendChild(host);+      await nextFrame();+      assertRendering(host);+      assert.deepEqual(log, [+        'render-host-attr',+        'render-host-prop',+        'render-host-node',+        'render-child-attr',+        'render-child-prop',+        'render-child-node',+      ]);+    });++    test('directives disconnect on disconnection', async () => {+      container.appendChild(host);+      await nextFrame();+      assertRendering(host);+      log.length = 0;+      container.removeChild(host);+      assertRendering(host);+      assert.deepEqual(log, [+        'disconnect-host-attr',+        'disconnect-host-prop',+        'disconnect-host-node',+        'disconnect-child-attr',+        'disconnect-child-prop',+        'disconnect-child-node',+      ]);+    });++    test('directives reconnect on reconnection', async () => {+      container.appendChild(host);+      await nextFrame();+      assertRendering(host);+      container.removeChild(host);+      log.length = 0;+      container.appendChild(host);+      assertRendering(host);+      assert.deepEqual(log, [+        'reconnect-host-attr',+        'reconnect-host-prop',+        'reconnect-host-node',+        'reconnect-child-attr',+        'reconnect-child-prop',+        'reconnect-child-node',+      ]);+    });++    test('directives reconnect and render on reconnection with pending render', async () => {+      container.appendChild(host);+      await nextFrame();+      assertRendering(host);+      container.removeChild(host);+      log.length = 0;+      host.requestUpdate();+      host.child.requestUpdate();+      container.appendChild(host);+      assertRendering(host);+      assert.deepEqual(log, [+        'reconnect-host-attr',+        'reconnect-host-prop',+        'reconnect-host-node',+        'reconnect-child-attr',+        'reconnect-child-prop',+        'reconnect-child-node',+      ]);+      log.length = 0;+      await nextFrame();+      assertRendering(host);+      assert.deepEqual(log, [+        'render-host-attr',+        'render-host-prop',+        'render-host-node',+        'render-child-attr',+        'render-child-prop',+        'render-child-node',+      ]);+    });++    test('directives reconnect on reconnection', async () => {

Done

kevinpschaaf

comment created time in 13 minutes

PR opened grafana/grafana

GraphNG: add initial flot to uplot graph migration

This aims to migrate the most basic settings

+221 -0

0 comment

3 changed files

pr created time in 13 minutes

Pull request review commentPolymer/lit-html

[lit-html] Add DisconnectableDirective implementation

 import {assert} from '@esm-bundle/chai';       assert.equal(a.shadowRoot, undefined);     }   );++  suite('disconnection handling', () => {+    let host: Host;+    const log: string[] = [];++    const d = directive(+      class extends DisconnectableDirective {+        id!: unknown;+        render(id: unknown) {+          log.push(`render-${id}`);+          return (this.id = id);+        }+        disconnectedCallback() {+          log.push(`disconnect-${this.id}`);+        }+        reconnectedCallback() {+          log.push(`reconnect-${this.id}`);+        }+      }+    );++    class Child extends LitElement {+      static properties = {+        attr: {type: String},+        prop: {type: String},+      };+      attr = 'default';+      prop = 'default';+      render() {+        return html`<div attr=${d('child-attr')} .prop=${d('child-prop')}>+          ${d('child-node')}+        </div>`;+      }+      get child() {+        return this.shadowRoot!.firstElementChild as Child;+      }+    }+    customElements.define('disc-child', Child);++    class Host extends LitElement {+      render() {+        return html`<disc-child attr=${d('host-attr')} .prop=${d('host-prop')}+          >${d('host-node')}</disc-child+        >`;+      }+      get child() {+        return this.shadowRoot!.firstElementChild as Child;+      }+    }+    customElements.define('disc-host', Host);++    const assertRendering = (host: Host) => {+      let child = host.child;+      assert.equal(child.getAttribute('attr'), 'host-attr');+      assert.equal(child.prop, 'host-prop');+      assert.equal(child.textContent?.trim(), 'host-node');+      child = child.child;+      assert.equal(child.getAttribute('attr'), 'child-attr');+      assert.equal(child.prop, 'child-prop');+      assert.equal(child.textContent?.trim(), 'child-node');+    };++    setup(() => {+      log.length = 0;+      host = new Host();+    });++    teardown(() => {+      if (host.isConnected) {+        container.removeChild(host);+      }+    });++    test('directives render on connection', async () => {+      container.appendChild(host);+      await nextFrame();+      assertRendering(host);+      assert.deepEqual(log, [+        'render-host-attr',+        'render-host-prop',+        'render-host-node',+        'render-child-attr',+        'render-child-prop',+        'render-child-node',+      ]);+    });++    test('directives disconnect on disconnection', async () => {+      container.appendChild(host);+      await nextFrame();+      assertRendering(host);+      log.length = 0;+      container.removeChild(host);+      assertRendering(host);+      assert.deepEqual(log, [+        'disconnect-host-attr',+        'disconnect-host-prop',+        'disconnect-host-node',+        'disconnect-child-attr',+        'disconnect-child-prop',+        'disconnect-child-node',+      ]);+    });++    test('directives reconnect on reconnection', async () => {+      container.appendChild(host);+      await nextFrame();+      assertRendering(host);+      container.removeChild(host);+      log.length = 0;+      container.appendChild(host);+      assertRendering(host);+      assert.deepEqual(log, [+        'reconnect-host-attr',+        'reconnect-host-prop',+        'reconnect-host-node',+        'reconnect-child-attr',+        'reconnect-child-prop',+        'reconnect-child-node',+      ]);+    });++    test('directives reconnect and render on reconnection with pending render', async () => {+      container.appendChild(host);+      await nextFrame();+      assertRendering(host);+      container.removeChild(host);+      log.length = 0;+      host.requestUpdate();+      host.child.requestUpdate();+      container.appendChild(host);+      assertRendering(host);+      assert.deepEqual(log, [

Done

kevinpschaaf

comment created time in 13 minutes

more