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

fluent-dom

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluent-dom - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

test/index.js

16

CHANGELOG.md
# Changelog
## Unreleased
- …
## fluent-dom 0.4.0
- Drop support for IE and old evergreen browsers. (#133)
Currently supported are: Firefox 52+, Chrome 55+, Edge 15+, Safari 10.1+,
iOS Safari 10.3+ and node 8.9+.
- Add the `cached-iterable` runtime dependency.
`CachedAsyncIterable` is now available from its own package rather than
from the `fluent` package.
- Modify the constructor to not require `window `element to be passed.
## fluent-dom 0.3.0
- Refactor the overlay sanitization methods into separate functions. (#189)

@@ -8,0 +22,0 @@ - Separate out CachedIterable and CachedAsyncIterable, and add a param to touchNext. (#191)

7

package.json
{
"name": "fluent-dom",
"version": "0.3.0",
"version": "0.4.0",
"description": "Fluent bindings for DOM",

@@ -42,4 +42,7 @@ "repository": {

"devDependencies": {
"jsdom": "^11.6.2"
"jsdom": "^11.12.0"
},
"dependencies": {
"cached-iterable": "^0.2.1"
}
}

@@ -19,3 +19,2 @@ import translateElement from "./overlay";

/**
* @param {Window} windowElement
* @param {Array<String>} resourceIds - List of resource IDs

@@ -26,3 +25,3 @@ * @param {Function} generateMessages - Function that returns a

*/
constructor(windowElement, resourceIds, generateMessages) {
constructor(resourceIds, generateMessages) {
super(resourceIds, generateMessages);

@@ -36,6 +35,4 @@

this.pendingElements = new Set();
this.windowElement = windowElement;
this.mutationObserver = new windowElement.MutationObserver(
mutations => this.translateMutations(mutations)
);
this.windowElement = null;
this.mutationObserver = null;

@@ -138,2 +135,15 @@ this.observerConfig = {

if (this.windowElement) {
if (this.windowElement !== newRoot.ownerDocument.defaultView) {
throw new Error(`Cannot connect a root:
DOMLocalization already has a root from a different window.`);
}
} else {
this.windowElement = newRoot.ownerDocument.defaultView;
this.mutationObserver = new this.windowElement.MutationObserver(
mutations => this.translateMutations(mutations)
);
}
this.roots.add(newRoot);

@@ -157,7 +167,16 @@ this.mutationObserver.observe(newRoot, this.observerConfig);

this.roots.delete(root);
// Pause and resume the mutation observer to stop observing `root`.
// Pause the mutation observer to stop observing `root`.
this.pauseObserving();
if (this.roots.size === 0) {
this.mutationObserver = null;
this.windowElement = null;
this.pendingrAF = null;
this.pendingElements.clear();
return true;
}
// Resume observing all other roots.
this.resumeObserving();
return this.roots.size === 0;
return false;
}

@@ -183,2 +202,6 @@

pauseObserving() {
if (!this.mutationObserver) {
return;
}
this.translateMutations(this.mutationObserver.takeRecords());

@@ -194,2 +217,6 @@ this.mutationObserver.disconnect();

resumeObserving() {
if (!this.mutationObserver) {
return;
}
for (const root of this.roots) {

@@ -196,0 +223,0 @@ this.mutationObserver.observe(root, this.observerConfig);

/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
/* global console */
import { CachedAsyncIterable } from "../../fluent/src/index";
import { CachedAsyncIterable } from "cached-iterable";

@@ -20,7 +20,7 @@ /**

*/
constructor(resourceIds, generateMessages) {
constructor(resourceIds = [], generateMessages) {
this.resourceIds = resourceIds;
this.generateMessages = generateMessages;
this.ctxs =
new CachedAsyncIterable(this.generateMessages(this.resourceIds));
this.ctxs = CachedAsyncIterable.from(
this.generateMessages(this.resourceIds));
}

@@ -31,2 +31,3 @@

this.onChange();
return this.resourceIds.length;
}

@@ -37,2 +38,3 @@

this.onChange();
return this.resourceIds.length;
}

@@ -158,4 +160,5 @@

onChange() {
this.ctxs =
new CachedAsyncIterable(this.generateMessages(this.resourceIds));
this.ctxs = CachedAsyncIterable.from(
this.generateMessages(this.resourceIds));
this.ctxs.touchNext(2);
}

@@ -162,0 +165,0 @@ }

@@ -11,12 +11,5 @@ import assert from "assert";

const mockWindow = {
MutationObserver: class MutationObserver {
takeRecords() {return new Set();}
disconnect() {}
}
};
suite("translateFragment", function() {
test("translates a node", async function() {
const domLoc = new DOMLocalization(mockWindow, ["test.ftl"], mockGenerateMessages);
const domLoc = new DOMLocalization(["test.ftl"], mockGenerateMessages);

@@ -34,3 +27,3 @@ const frag = document.createDocumentFragment();

test("does not inject content into a node with missing translation", async function() {
const domLoc = new DOMLocalization(mockWindow, ["test.ftl"], mockGenerateMessages);
const domLoc = new DOMLocalization(["test.ftl"], mockGenerateMessages);

@@ -37,0 +30,0 @@ const frag = document.createDocumentFragment();

import assert from 'assert';
import translateElement from '../src/overlay';
import {elem} from './util';
import {elem} from './index';

@@ -5,0 +5,0 @@ suite('Localized text markup', function() {

import assert from 'assert';
import translateElement from '../src/overlay';
import {elem} from './util';
import {elem} from './index';

@@ -5,0 +5,0 @@ suite('Top-level attributes', function() {

import assert from 'assert';
import translateElement from '../src/overlay';
import {elem} from './util';
import {elem} from './index';

@@ -5,0 +5,0 @@ suite('Child without name', function() {

import assert from 'assert';
import translateElement from '../src/overlay';
import {elem} from './util';
import {elem} from './index';

@@ -5,0 +5,0 @@ suite('Text-semantic argument elements', function() {

Sorry, the diff of this file is not supported yet

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