Code Monkey home page Code Monkey logo

i18n-number's Introduction

i18n-number's People

Contributors

t2ym avatar

Watchers

 avatar  avatar

i18n-number's Issues

[Polymer 2.x][Edge 14][HTMLImports] Missing disconnect() method in MutationObserver

[Polymer 2.x][Edge 14][HTMLImports] missing disconnect() method in MutationObserver

Error Message from WCT

Windows 10 microsoftedge 14 Tests failed: Error thrown outside of test function: Object doesn't support property or method 'disconnect'
  A.prototype.disconnectedCallback at /components/webcomponentsjs/webcomponents-lite.js:145
                     A.prototype.a at /components/webcomponentsjs/webcomponents-lite.js:143
                Anonymous function at /components/webcomponentsjs/webcomponents-lite.js:42

Related Code in HTML Imports: src/html-imports.js

    processImportsIfLoadingDone() {
      // Wait until all resources are ready, then load import resources.
      if (this.inflight) {
        return;
      }

      // Stop observing, flatten & load resource, then restart observing <head>.
      this.dynamicImportsMO.disconnect();
      this.flatten(document);
  • The validity of the object this.dynamicImportsMO has not been tracked in debugger.
  • Not Reproducible on Edge 13

[4.0] Remove dependency on Polymer library

[4.0] Remove dependency on Polymer library

Status

Tasks

  • Move @polymer/polymer from dependencies to devDependencies
  • Drop Safari 9 support
    • Remove intl package dependency
  • bower.json with BSD-2-Clause as license
  • Add lit-html dependency
  • Remove intl loading mechanism
  • Convert to lit-html rendering
    • Remove @polymer/polymer imports
    • Convert properties and observers
  • Support IE11 and Edge with custom elements v1 polyfill
    • Temporarily insert polyfill.js contents from i18n-element/polyfill.js
    • Import a separate polyfill.js from an independent npm module for polyfill.js
      • Create npm package wc-putty and import
  • Convert tests
    • No Polymer methods
    • Add some waits
  • Convert demo
    • Remove intl from extraDependencies in polymer.json
  • Documentation
    • Decent comments
    • API Docs page

Design Issues

  • How to port notifyPath() feature from Polymer?
    • Just call _onOptionsPropertyChanged()
  • Is reflectToAttribute feature required? No
  • root property for shadowRoot to imitate a Polymer element
  • Should attachShadow() be put off until the first rendering like i18n-format? Yes
    • i18n-element tests fail with <plural-gender-element>
  • Should assignment of this.lang with the default value be put off until connectedCallback? Yes
  • Is importMeta property necessary? No.

Issues

  • document.createElement('i18n-number') fails with "The result must not have attributes"
    • Fix: Put off setting this.lang in the constructor to the next microtask timing
    • Fix: Add 'null' guards for lang property
  • lang attribute/property is unexpectedly set to "en"
window.t = document.createElement('template');
t.innerHTML = '<i18n-number id="overridden-lang" lang="fr">12.34</i18n-number>'
document.body.appendChild(t.content);
document.querySelector('i18n-number#overridden-lang').lang === 'fr' // must be true, actually false
  • Root Cause: lang has to be set at connectedCallback instead of the microtask timing after constructor

[3.0][demo] Build demo for static servers

[3.0][demo] Build demo for static servers

Demo

Prerequisite for Building and Serving Demo

    npm install -g polymer-cli

On-the-fly Build

    # Serve at http://localhost:8080/components/i18n-number/demo/
    polymer serve --npm --module-resolution=node -p 8080

Static Builds

  • Build
    polymer build
  • Targets
target browser minify bundled
build/esm-unbundled es6,modules no no
build/esm-bundled es6,modules yes yes
build/es6-bundled es6 yes yes
build/es5-bundled es5 yes yes
  • Serve
    # Serve at http://localhost:8080/
    cd build/{esm-unbundled|esm-bundled|es6-bundled|es5-bundled}
    python -m SimpleHTTPServer 8080 # or any HTTP(S) server

[3.0][webcomponents.org] Demo on webcomponents.org does not work

[3.0][webcomponents.org] Demo on webcomponents.org does not work

Demo link on webcomponents.org

Suspected Root Cause

  • Failing to load NPM modules as they are inexistent on the generated server environment

Fix

Language fallback is unreliable in Intl.js locale module dynamic loading

Normalization, i.e., case sensitive URL path name generation of Intl.js locale data modules are too simple and unreliable.

For example, ZH-haNS-cn is incorrectly normalized to zh-HANS-CN, which results in file not found error and thus must be changed to zh-Hans-CN.

For language fallback, an inexistent locale ja-CA directly falls back to en instead of ja.

[Enhancement] Customize paths to Intl.js modules

Paths to Intl.js modules are currently hard-coded as ../intl/dist/Intl.min.js and ../intl/locale-data/jsonp/{locale}.js, which is inflexible and would be inconvenient if i18n-number.html and other modules are vulcanized.

A convenient and flexible method to customize the hard-coded paths to the modules like this is desired.

<meta name="intl-js-path" content="/dynamic-components/intl">

[performance] new Intl.NumberFormat is slow

[performance] new Intl.NumberFormat is slow

Possible Fix

  • Since new Intl.NumberFomrat is called with lang and options, observe these parameters and cache the new Intl.NumberFormat(lang, options) object for later usage
  • The expected reliable caching algorithm is not as simple as expected with performance in consideration.

Notes

  • Just calling .format() method is 100 times faster than instantiating Intl.NumberFormat on each call
  • The fix priority is low since <i18n-number> should not be used so heavily

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.