當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript VirtualDOM.realize方法代碼示例

本文整理匯總了TypeScript中@phosphor/virtualdom.VirtualDOM.realize方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript VirtualDOM.realize方法的具體用法?TypeScript VirtualDOM.realize怎麽用?TypeScript VirtualDOM.realize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@phosphor/virtualdom.VirtualDOM的用法示例。


在下文中一共展示了VirtualDOM.realize方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

      it('should connect a node to a command', () => {
        let called = false;
        const command = 'commandlinker:connect-node';
        const commands = new CommandRegistry();
        const linker = new CommandLinker({ commands });
        let node: HTMLElement;
        let vnode: VirtualNode;
        const disposable = commands.addCommand(command, {
          execute: () => {
            called = true;
          }
        });

        vnode = h.div({ dataset: linker.populateVNodeDataset(command, null) });
        node = VirtualDOM.realize(vnode);
        document.body.appendChild(node);

        expect(called).to.equal(false);
        simulate(node, 'click');
        expect(called).to.equal(true);

        document.body.removeChild(node);
        linker.dispose();
        disposable.dispose();
      });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:25,代碼來源:commandlinker.spec.ts

示例2: createButtonNode

 /**
  * Create a button node for the dialog.
  *
  * @param button - The button data.
  *
  * @returns A node for the button.
  */
 createButtonNode(button: IButton): HTMLElement {
   let className = this.createItemClass(button);
   // We use realize here instead of creating
   // nodes with document.createElement as a
   // shorthand, and only because this is not
   // called often.
   return VirtualDOM.realize(
     h.button({ className },
           this.renderIcon(button),
           this.renderLabel(button))
   );
 }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:19,代碼來源:dialog.ts

示例3: createHeader

 /**
  * Create the header of the dialog.
  *
  * @param title - The title of the dialog.
  *
  * @returns A widget for the dialog header.
  */
 createHeader(title: HeaderType): Widget {
   let header: Widget;
   if (typeof title === 'string') {
     header = new Widget({ node: document.createElement('span') });
     header.node.textContent = title;
   } else {
     header = new Widget({ node: VirtualDOM.realize(title) });
   }
   header.addClass('jp-Dialog-header');
   Styling.styleNode(header.node);
   return header;
 }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:19,代碼來源:dialog.ts

示例4: it

      it('should render the model into a virtual DOM table', () => {
        let model = new CSVModel({ content: CSV_DATA });
        let table = new TestTable();
        table.model = model;

        let rendered = VirtualDOM.realize(table.render() as VirtualElement);
        let rows = rendered.getElementsByTagName('tr');
        let cols = rendered.getElementsByTagName('th');
        expect(rows).to.have.length(DISPLAY_LIMIT);
        expect(cols).to.have.length(4);

        model.dispose();
        table.dispose();
      });
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:14,代碼來源:table.spec.ts

示例5: createBody

 /**
  * Create the body of the dialog.
  *
  * @param value - The input value for the body.
  *
  * @returns A widget for the body.
  */
 createBody(value: BodyType<any>): Widget {
   let body: Widget;
   if (typeof value === 'string') {
     body = new Widget({ node: document.createElement('span') });
     body.node.textContent = value;
   } else if (value instanceof Widget) {
     body = value;
   } else {
     body = new Widget({ node: VirtualDOM.realize(value) });
   }
   body.addClass('jp-Dialog-body');
   Styling.styleNode(body.node);
   return body;
 }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:21,代碼來源:dialog.ts

示例6: it

 it('should style descendant nodes for the given tag', () => {
   let vnode = h.div({}, [h.span(), h.div({}, h.span())]);
   let node = VirtualDOM.realize(vnode);
   Styling.styleNodeByTag(node, 'span');
   expect(node.querySelectorAll('.jp-mod-styled').length).to.equal(2);
 });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:6,代碼來源:styling.spec.ts

示例7: it

 it('should create a real DOM node from a virtual DOM node', () => {
   let node = VirtualDOM.realize(h.div([h.a(), h.img()]));
   expect(node.nodeName.toLowerCase()).to.equal('div');
   expect(node.children[0].nodeName.toLowerCase()).to.equal('a');
   expect(node.children[1].nodeName.toLowerCase()).to.equal('img');
 });
開發者ID:afshin,項目名稱:phosphor,代碼行數:6,代碼來源:index.spec.ts

示例8: createCellDragImage

  export function createCellDragImage(
    activeCell: Cell,
    selectedCells: nbformat.ICell[]
  ): HTMLElement {
    const count = selectedCells.length;
    let promptNumber: string;
    if (activeCell.model.type === 'code') {
      let executionCount = (activeCell.model as ICodeCellModel).executionCount;
      promptNumber = ' ';
      if (executionCount) {
        promptNumber = executionCount.toString();
      }
    } else {
      promptNumber = '';
    }

    const cellContent = activeCell.model.value.text.split('\n')[0].slice(0, 26);
    if (count > 1) {
      if (promptNumber !== '') {
        return VirtualDOM.realize(
          h.div(
            h.div(
              { className: DRAG_IMAGE_CLASS },
              h.span(
                { className: CELL_DRAG_PROMPT_CLASS },
                '[' + promptNumber + ']:'
              ),
              h.span({ className: CELL_DRAG_CONTENT_CLASS }, cellContent)
            ),
            h.div({ className: CELL_DRAG_MULTIPLE_BACK }, '')
          )
        );
      } else {
        return VirtualDOM.realize(
          h.div(
            h.div(
              { className: DRAG_IMAGE_CLASS },
              h.span({ className: CELL_DRAG_PROMPT_CLASS }),
              h.span({ className: CELL_DRAG_CONTENT_CLASS }, cellContent)
            ),
            h.div({ className: CELL_DRAG_MULTIPLE_BACK }, '')
          )
        );
      }
    } else {
      if (promptNumber !== '') {
        return VirtualDOM.realize(
          h.div(
            h.div(
              { className: `${DRAG_IMAGE_CLASS} ${SINGLE_DRAG_IMAGE_CLASS}` },
              h.span(
                { className: CELL_DRAG_PROMPT_CLASS },
                '[' + promptNumber + ']:'
              ),
              h.span({ className: CELL_DRAG_CONTENT_CLASS }, cellContent)
            )
          )
        );
      } else {
        return VirtualDOM.realize(
          h.div(
            h.div(
              { className: `${DRAG_IMAGE_CLASS} ${SINGLE_DRAG_IMAGE_CLASS}` },
              h.span({ className: CELL_DRAG_PROMPT_CLASS }),
              h.span({ className: CELL_DRAG_CONTENT_CLASS }, cellContent)
            )
          )
        );
      }
    }
  }
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:71,代碼來源:celldragutils.ts


注:本文中的@phosphor/virtualdom.VirtualDOM.realize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。