This package has been deprecated

Author message:

update to @phosphor/widgets package

phosphor-nodewrapper
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

phosphor-nodewrapper

Build Status Coverage Status

A base class for creating objects which wrap a DOM node.

API Docs

Package Install

Prerequisites

npm install --save phosphor-nodewrapper

Source Build

Prerequisites

git clone https://github.com/phosphorjs/phosphor-nodewrapper.git
cd phosphor-nodewrapper
npm install

Rebuild

npm run clean
npm run build

Run Tests

Follow the source build instructions first.

# run tests in Firefox 
npm test
 
# run tests in Chrome 
npm run test:chrome
 
# run tests in IE 
npm run test:ie

Build Docs

Follow the source build instructions first.

npm run docs

Navigate to docs/index.html.

Supported Runtimes

The runtime versions which are currently known to work are listed below. Earlier versions may also work, but come with no guarantees.

  • IE 11+
  • Firefox 32+
  • Chrome 38+

Bundle for the Browser

Follow the package install instructions first.

npm install --save-dev browserify
browserify myapp.js -o mybundle.js

Usage Examples

Note: This module is fully compatible with Node/Babel/ES6/ES5. Simply omit the type declarations when using a language other than TypeScript.

import { NodeWrapper } from 'phosphor-nodewrapper';
 
 
class Button extends NodeWrapper {
 
  static createNode(): HTMLElement {
    var node = document.createElement('button');
    var icon = document.createElement('span');
    var text = document.createElement('span');
    node.appendChild(icon);
    node.appendChild(text);
    return node;
  }
 
  constructor(text?: string) {
    super();
    this.addClass('Button');
    if (text) this.text = text;
  }
 
  get text(): string {
    return this.node.lastChild.textContent;
  }
 
  set text(text: string) {
    this.node.lastChild.textContent = text;
  }
 
  get disabled(): boolean {
    return this.hasClass('mod-disabled');
  }
 
  set disabled(disabled: boolean) {
    this.toggleClass('mod-disabled', disabled);
  }
}

Readme

Keywords

Package Sidebar

Install

npm i phosphor-nodewrapper

Weekly Downloads

13

Version

1.0.6

License

BSD-3-Clause

Last publish

Collaborators

  • sccolbert