Code Monkey home page Code Monkey logo

Comments (3)

ro0gr avatar ro0gr commented on June 14, 2024 2

I believe it can be replaced by leveraging of the document.activeElement in a custom property, smth like:

// pseudo code
export function hasFocus(selector, userOptions = {}) {
  return {
    isDescriptor: true,

    get(key) {
      let options = { pageObjectKey: key, ...userOptions };

      return findOne(this, selector, options) === document.activeElement;
    }
  };
}

which could be used like the rest of the page object props:

const element = create({
  scope: '.selector',
  hasFocus: hasFocus()
});

hope it helps and would work for you!

Also I'm definitely open to accept an update for the is deprecation section.

from ember-cli-page-object.

gnclmorais avatar gnclmorais commented on June 14, 2024

Hey @ro0gr, I’d be happy to contribute with an update/improvement. Would there be interested in adding this hasFocus (or something similar) to ember-cli-page-object as an official helper as well?

from ember-cli-page-object.

ro0gr avatar ro0gr commented on June 14, 2024

hey @gnclmorais! though I feel like it isn't a super frequently used feature, I'm not opposed to have this included by default.

Just a remark about possible implementation... The suggested approach with findOne( does contradict a bit with what we currently do for the rest of similar properties in v1. At the moment we try to respect the multiple option, which in its turn is deprecated now, and it's going to be removed in v2. That's why I think for the new property it'd be better to use findOne, even if we become inconsistent with the rest of props.

from ember-cli-page-object.

Related Issues (20)

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.