Coder Social home page Coder Social logo

wait-for-element.js's Introduction

wait-for-element.js Build Status

This library provide a function which wait until an element is visible.

Installation

npm install wait-for-element

Dependency

  • Promise API

if you use it with non promise support browser, should load Promise polyfill like ES6-Promise.

if you use it with old browser.

if (Element && !Element.prototype.matches) {
    var proto = Element.prototype;
    proto.matches = proto.matchesSelector ||
    proto.mozMatchesSelector || proto.msMatchesSelector ||
    proto.oMatchesSelector || proto.webkitMatchesSelector;
}

or use polyfill.

wait-for-element do feature detection and use either one of the two.

Usage

For details, please see Example.

/**
 * Wait until an element that is matched the selector is visible.
 * @param {string} selector the css selector
 * @param {number} timeout the timeout is millisecond. default:2000ms
 * @returns {Promise}
 */
var waitForElement = require("wait-for-element");
waitForElement("#js-element").then(function (element) {
    alert("Found #js-element");
}).catch(console.error.bind(console));

Tests

npm test

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

wait-for-element.js's People

Contributors

azu avatar

Stargazers

 avatar Alex Strizhak avatar Hamsterwork avatar  avatar  avatar Dmitri Pyatkov avatar Igor Kuznetsov avatar Kohei Ito avatar horyu avatar Nikos avatar tiansin avatar Yassine A. avatar Yuumi Yoshida avatar Shawn Halpenny avatar Harald avatar Yoichi Dan avatar Grzegorz Witos avatar  avatar Yuya Saito avatar James Homer avatar Aziz Gazanchiyan avatar Jidé avatar Wayne Patterson avatar Jason Morganson avatar Adam Jensen avatar J. J. Knudsen avatar Adir Amsalem avatar  avatar Yusuke Goto avatar Adam Veary avatar Roman Vasilev avatar  avatar David Chase avatar Filip Malinowski avatar yahata avatar takafumi tsuchida avatar Naohiro Nakajima avatar Kuma Taro avatar taku_eof / Taku WATABE / 渡部巧 avatar Joe avatar trapple avatar OKUNOKENTARO avatar Kotaro Yoshimatsu avatar Kenta Mori avatar floydwch avatar gomi_ningen avatar  avatar Ryoji Miyazato avatar Atsushi NAGASE avatar Kiyoshi Nomo avatar

Watchers

 avatar James Cloos avatar  avatar

wait-for-element.js's Issues

Error in console

I am getting an error in the console if the element has not been created. How can I avoid this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.