New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rangefix

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rangefix

Workaround for browser bugs in Range.prototype.getClientRects and Range.prototype.getBoundingClientRect.

  • 0.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
increased by46.24%
Maintainers
1
Weekly downloads
 
Created
Source

Workaround for browser bugs in Range.prototype.getClientRects and Range.prototype.getBoundingClientRect.

In particular:

  • A Chrome bug which results in selections spanning multiple nodes returning rects for all the parents of the endContainer. See https://code.google.com/p/chromium/issues/detail?id=324437. This bug was fixed in Chrome 55.
  • A similar bug in Firefox but only triggered with images near the edge of a node.
  • A regression in Chrome 55 where images get no rectangle when they are wrapped in a node and you select across them.
  • A bug in IE (<=10) which results in scaled rectangles when using the browser's zoom feature.

Usage

Include the rangefix.js library in your project.

Replace instances of Range.prototype.getClientRects/getBoundingClientRect with RangeFix.getClientRects/getBoundingClientRect:

range = document.getSelection().getRangeAt( 0 );

// Before
rects = range.getClientRects();
boundingRect = range.getBoundingClientRect();

// After
rects = RangeFix.getClientRects( range );
boundingRect = RangeFix.getBoundingClientRect( range );

Demo

http://edg2s.github.io/rangefix/

FAQs

Package last updated on 26 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc